CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 7/4/2006 3:38:06 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 0 Views: 46 Favorited: 0 Favorite
1 Items, 1 Pages 1 |< << Go >> >|
azmanamutalib
Asp.Net User
How do we navigate using treeview postback?7/4/2006 3:38:06 AM

0

Hello everyone.  I have to re-post this as I have yet to receive any response.  I hope someone will help me this time.  Thanks.

I am experimenting navigation using TreeView postback.  This is how it goes?

Upon successful login in a login page, a main page is displayed.  The main page uses a Master page that contains a TreeView bound to a sitemap.

In the main page, upon clicking a TreeView node, I want to programmatically navigate to a different page by constructing on-the-fly a URL and then redirecting to it (the URL).  This is where I got stuck at.

The code is as follows:

Web.sitemap:

<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >

      <siteMapNode title="Main" description="Main">

<siteMapNode title="Submit" description="Submit ECS"/>

<siteMapNode title="Verify" description="Verify ECS" />

<siteMapNode title="Approve" description="Approve ECS"  /> 

</siteMap>

Main.master:

<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />

<asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1" OnSelectedNodeChanged="TreeView1_SelectedNodeChanged" ShowLines="True">

</asp:TreeView>

Main.master.c:

protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)

{

      // Get name of current user

      string currentUser = Membership.GetUser().UserName.ToString();

      // Construct URL on-the-fly and redirect to it

      switch (TreeView1.SelectedNode.Text)

      {

      case "Main":

                  Response.Redirect("Main.aspx");

                  break;

      case "Submit":

                  Response.Redirect("SubmitECS.aspx?User=" + currentUser);

                  break;

      case "Verify":

                  Response.Redirect("VerifyECS.aspx?User=" + currentUser);

                  break;

      case "Approve":

                  Response.Redirect("ApproveECS.aspx?User=" + currentUser);

                  break;

      }

}

Main.aspx:

<%@ Page Language="C#" MasterPageFile="Main.master" AutoEventWireup="true" CodeFile="Main.aspx.cs" Inherits="Main" Title="Navigation Using TreeView" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

</asp:Content>

 

After reading some relevant posts in this forum, I have learnt that:

  • With TreeView, we can either navigate or postback. (I would have opted for navigation had the URLs been hard-coded.  But since I have to construct URLs on-the-fly, I have to go for postback.)

  • To postback, each TreeNode?s NavigateUrl property should remain empty.  On the other hand, to navigate, each TreeNode?s NavigateUrl property should be assigned with proper value.  (That is why, if you notice, I omit url attribute for each siteMapNode element in Web.sitemap. I assume url attribute is bound to TreeNode?s NavigateUrl property.)

  • In order for Selection event (e.g. SelectedNodeChanged) to fire, we should make TreeView postback, thus, the empty NavigateUrl property. (Notice that I construct the URL on-the-fly in the SelectedNodeChanged event handler.)

 

However, I encounter 2 problems:

  1. None of the TreeView nodes seems clickable.  When mouse is hovered over a node, the mouse cursor remains an arrow, instead of a pointing finger. 
  2. As a result, the SelectedNodeChanged event never gets fired, even if I ?force-click? any node in the TreeView. 

With these problems, I fail to programmatically navigate to a different page upon clicking a node in the TreeView. 

I observe that only if I add url attributes (with proper values) in siteMapNode elements in Web.sitemap, will the TreeView nodes become clickable.  However, consequently, this makes the TreeView navigate, instead of postback, therefore not firing the SelectedNodeChanged event, which I need to handle, in order to construct the URL on-the-fly.

I am sure I have overlooked something or done something wrong but I just don?t know what it is. 

Would appreciate your valuable advice.  Thanks.

1 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Professional ASP.NET 2.0 Authors: Bill Evjen, Scott Hanselman, Farhan Muhammad, Srinivasa Sivakumar, Devin Rader, Pages: 1253, Published: 2005
PROFESSIONAL ASP.NET 2.0, SPECIAL EDITION Authors: Bill Evjen, Scott Hanselman, Devin Rader, Farhan Muha, Pages: 1586, Published: 2006
Professional ASP.NET 2.0 security, membership, and role management Authors: Stefan Schackow, Pages: 611, Published: 2006
Pro ASP.NET 2.0 in VB 2005 Authors: Laurence Moroney, Matthew MacDonald, Pages: 1253, Published: 2006
ASP.NET 2.0: a developer's notebook Authors: Wei Meng Lee, Pages: 326, Published: 2005

Web:
How to Navigate Using TreeView Postback? - ASP.NET Forums However, consequently, this makes the TreeView navigate, instead of postback, therefore not firing the SelectedNodeChanged event, ...
TreeView Web Server Control Overview Instead of raising a selection event to navigate to a page when a node is clicked, ... Typically, you should handle postback events when the TreeView control is in selection mode ... Using the TreeView Control with UpdatePanel Controls ...
ASP.NET 2.0 Treeview No Postback? do *anything* besides (a) immediately PostBack, or (b) immediately navigate away from the page, when a user selects a node in the TreeView. ...
How to maintain Tree view state in master page when navigating to ... So here navigate to URL is used no post back . But doing so I lose the tree view state i,e If expanded by user and navigate it comes back as ...
ASP.NET Classic Controls - Treeview Forum - NodeClick event ... You are using load-on-demand, which requires a postback. ... When you click on the +/-, there is no postback and you can navigate the tree. ...

LinkButton OnClick Method - ng.asp-net-forum ... treeview node.parent = null for non-root nodes · masterpage question · how do we navigate using treeview postback? apply css in master page ...
JScript runtime error - general_asp.net.client_side_web_development help! using treeview without autopost · how do we can calculate number of sundays between ... how can i create menu in javascript to navigate .aspx page ? ...






aspx to pdf on fly

how to refresh a page in asp.net

using replace with unicode characters

exception not firing

how to get my website in google search results

password sending

timing a method

character counter in repeater

masked textbox

image is not displaying

securing a web application c#

general help needed

control differences

is it possible to databind a textbox...i'm hella new to this

regular expression

test if texbox left empty

database update - how to do it and do no harm to data?

cd based training....

question dealing with this error number bc30311

getting values from usercontrol's datatable and display it in .aspx?

gridview footer total

login page

expected type is int32 error

how can i get this?

streaming audio and video

expert advice web vs windows application

error message

reseting dropdownlist selection?

treeview control does not display

highlighting radiobuttonlist text on selection?

   
  Privacy | Contact Us
All Times Are GMT