28 Ocak 2010 Perşembe

Disable Web Page Auto Scroll Up

If you have a long web page and when you are at the end of the page, whenever a postback is occured it will scroll up to beginning of the page.

To avoid this irritating behaviour, paste the follaowing line to your page specifications:

<%@ Page MaintainScrollPositionOnPostback="True" %>

7 Ocak 2010 Perşembe

A problem with publishing web applications in .NET ?

When I tried to publish my web application I saw the following exception:

The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.

A name was started with an invalid character. Error processing resource 'file://server-name/f$/Intranet/Web/Project
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Project"%> -^ 
 Solution:  
When multiple versions of ASP.NET are installed on a computer, ASP.NET is said to be running side-by-side. In this setup, Internet Information Services (IIS) needs to know which version of the ASP.NET ISAPI (aspnet_isapi.dll) should process a page in an ASP.NET application. ASP.NET IIS Registration Tool (Aspnet_regiis.exe) allows an administrator or installation program to easily update the script maps for an ASP.NET application to point to the ASP.NET ISAPI version that is associated with the tool.

How to use the tool?

---Open command prompt , go to the following path: 
%windir%\Microsoft.NET\Framework\v2.0.50727
 ---run aspnet_regiis -ua 
---when that finishes run aspnet_regiis -i

---and browse your application. :) 
Yours Sincerely...

Querying hierarchical relationships between Oracle DB records...

The start with .. connect by clause make us to select data which has a hierarchical relationship.
For example in  Country -> city -> street or Manager -> Employee relations...


Hierarchical Data Structure



PositionsTable



This clause runs recursively, starts with a specified point and returns all the chain of records ...
Query:
SELECT * FROM POSITIONS
START WITH ID = 9
CONNECT BY PRIOR MANAGER_ID =ID;

Result Of The Query:

ID POSITION                        MANAGER_ID
---  -------------------------------    ----------------------
9   DOCUMENTER                 4

4   IT TEAM LEADER             3

3   PROJECT MANAGER       1

1   SOFTWARE DIRECTOR   0


5 Ocak 2010 Salı

Textbox does not fire TextChanged Event in User Controls...

TextChanged event is fired when the mouse leaves the textbox. This means that to fire that event you have to click on another object in the page after typing a character . To get rid of this extra click you can do this:

 protected void Page_Load(object sender, EventArgs e)
{
       if (!IsPostBack)
       {
         TextBox1.Attributes.Add("OnKeyUp", "javascript:myPostBack()");
        }
}

and paste the following code to your html file under the head tag:

< script type="text/javascript" >
function myPostBack()
{  
  __doPostBack("","");
}
< /script >



After that in every keystroke, TextChanged event will be fired by textbox...

Yours sincerely

Removing nodes from .NET TreeViews...

Unfortunetely its complicated to remove a node from a treeview in .NET. After a long time I solved this problem;

If you want to remove the selected node and
  • if the selected node has got a parent, remove it like that:  TreeView1.SelectedNode.Parent.ChildNodes.Remove(TreeView1.SelectedNode);
  • else if the selected node has not got a parent, remove it like that: TreeView1.Nodes.Remove(TreeView1.SelectedNode);
 
In same way, if you want to remove all the child nodes of the selected node, remove the child nodes like that;

int cnt = TreeView1.SelectedNode.ChildNodes.Count;
for (int i = cnt - 1; i >= 0; i--)
 {
     TreeNode myChild = TreeView1.SelectedNode.ChildNodes[i];
     TreeNode myParent =TreeView1.SelectedNode.ChildNodes[i].Parent;                        
      myParent.ChildNodes.Remove(myChild);
 }


Yours sincerely...

A problem with connecting to Oracle Server via .NET application...

If you can connect to Oracle Server from Toad or Oracle Enterprise Manager but can not connect via .NET application, probably visual studio is using a different tnsnames.ora file and this file is not up to date. To find this file and change its content follow the steps below:
  1. Click Right on "My Computer" icon and select "Properties" option,
  2. Click "Advanced" menu item and push the "Environment Variables" button,
  3. Click on "PATH" item and push the "Edit" button,
  4. Look at the content of the "variale value",
  5. You should look for the paths like "....Client_1\NETWORK\ADMIN " entries in this stream. These paths includes tnsnames.ora files. Examine these files and update them.
  6. Close "my computer" window.
  7. Try to connect again.
Good Luck!!