Category Archives: SiteMapDataSource

Treeview - SelectedNodeChanged event never fired

Hi

I have a Treeview control on my master page, the treeview is bound to a sitemap.

<asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1" NodeIndent="10" OnSelectedNodeChanged="TreeView1_SelectedNodeChanged" ShowCheckBoxes="All" AutoGenerateDataBindings="False">
   <DataBindings
>
      <asp:TreeNodeBinding DataMember="SiteMapNode" NavigateUrl="~/Default.aspx" NavigateUrlField="Url" Text="Title" TextField="Title" ToolTipField="Description" Value="Title"
/>
   </DataBindings
>
</asp:TreeView
>

But when I select a node in the view, the SelectedNodeChanged event isn't fired. The site just navigates to the new page.
ViewState is enabled.

Thanks for your help in advance.

Hi,
  The TreeView can do either 1 of 2 things.  Navigate or postback.  If it navigates, then you simply load the next page regardless of what page it is (the same page or different).  If it posts back, then it fires events on the same page.  Since you have navigate urls, that implies you are navigating and you won't get postback events.
--
Danny

Hi Danny

Thanks for your reply. I've reached the same conclusion, after several of hours debugging my app and discusses with colleges :)
Shame we don't live in the same timezone, you could have safed me a lot of wasted time.
Thanks again

///Rune 

I've searched numerous pages about this issue, and this post seems to sum-up the consensus.

Surely a TreeView and web.sitemap is one of the most common approaches to Navigation in ASP.NET 2005 (notice that it's on the "Navigation" tab in the toolbar). So why are navigating and coding (postback) mutually exclusive?

I used to get around this oddity of not having a SelectedNodeChange event (before the RTM) using the Page.SaveStateComplete event like this:

If masterTreeView.SelectedValue <> "" Then
   masterTreeView.SelectedNode.Expand()
End If

And it worked okay; but now even that won't work. It's like MS is going out of their way to make things more difficult. All I want is the exact same functionality as the +/- signs, but without seeing the symbols (our designers decision, not mine), but you're saying this is impossible now?

Well, after a few hours and way more code than I would have liked, I have the previous functionality back again. I'm basically doing all the expand/collapse functionality on my own in the SaveStateComplete. If you don't want to use the +/- symbols, you're in trouble.

yekcim1125

Surely a TreeView and web.sitemap is one of the most common approaches to Navigation in ASP.NET 2005 (notice that it's on the "Navigation" tab in the toolbar). So why are navigating and coding (postback) mutually exclusive?

Here's an example that might help explain this.  Lets say you have a TreeView on a page at:  http://www.msn.com/testpage.aspx  And lets say you have another (or even an identically coded) TreeView on a page at:  http://www.microsoft.com/somepage.aspx.  Lets say the first TreeView has a node with a NavigateUrl=http://www.microsoft.com/somepage.aspx.  If you are viewing the msn page and you click on the link to the microsoft.com page, would you expect that a SelectedNodeChanged event fires on the msn site?  the microsoft site?  neither? 

I think the obvious answer is neither.  There isn't any difference between this scenario and navigating to another page on the same site except that this is more clear (I think).  That is why navigation and postbacks are mutually exclusive.  Submitting a form and navigating to a new url are separate actions. 

If you think it should act a different way, I'd be happy to listen to your feedback.  Thanks.
--
Danny 

 

Is there a way to make the treeview generate events knowingly instead of on postback?

Basically I want to use the treeview the way you do when you install Visual Studio 2005 (tri-state checkbox). I think the treeview lacks some flexibility. Is there a way to enable event firing programmatically.

I am using the TreeView in ASP .Net 2.0

I would like to be able to browse a document via the NavigateUrl on a treenode in a separate frame to the treeview, as specified by the Target="blah" on the node. I would then like to be able to indicate the currently selected node, which should be the node that was navigated/selected.

At the moment I can only indicate the parent of the node. When there are many children, I cannot indicated the currently navigated/selected node

What I don't understand is; Why can't the Select events fire if the target is specifying a different location(frame)  to the treeview (frame)?

Without this feature it seems impossible to indicate to the user which document is the currently navigated/selected node.

Regards

Mike

first, same level nodes must have different values to distinguish selected node. Else treeview shows parent node selected.

second, if you use navigate url treeview works in navigate mode and disables selection events. So you cannot determine the selected tree node.

To solve this you can try to populate tree node texts with javascript that populates some hidden field values at the target frame...

Extra information about treenode class : http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.treenode.aspx

Ozan K. BAYRAM

Thanks so much for this post.  I spent several hours fighting this issue and was pretty close to giving up.  A real world example that worked!

 

 

 

Can you answer a simple question?  What event do I need to register to handle this?

protected

virtual void SMI_CommandTest(Object sender, TreeNodeEventArgs e)

 

[RESOLVED] Removing a sitemapnode

I am developing an ASP.NET web page with C#.  I have a sitemap document but I want to hide certain nodes based on the user's credentials.  However, I am having problems with my code removing the actual node.  Visual Studio runs the program with no errors.  However, the node is still there.  Below is the code I have developed for this.  The node changes text to "it worked" as I hope written.  However, it will not remove itself.  I can get the item to be disabled, change enablement, but I need to hide it completely from the viewers view - not the document.  Could someone help me with this?

protected void Menu1_MenuItemDataBound(object sender, MenuEventArgs e)
    {


        foreach(char f in e.Item.Text)
        {
            if (e.Item.Text == "Student Verification")
            {
                try
                {
                    myMenuItem = e.Item;
                    myMenuItem.Text = "It Worked";
                    Menu1.Items.Remove(myMenuItem);
                }
                catch (Exception ex)
                {
                    string exstring = Convert.ToString(ex);
                }
            }


        }
    }


 

Here is the code that worked for me


<div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">                        if (e.Item.Parent != null)</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">                        {</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">                            e.Item.Parent.ChildItems.Remove(e.Item);</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">                        }</div> <div></div>

if (e.Item.Parent != null)
{
      e.Item.Parent.ChildItems.Remove(e.Item);
}


I used this in a scenario where I check whether the sitemapnode has an attribute "visible".
If so, and its value = "false", then I would remove the node. 

Another way to do this is on the Page_Load event where the menu resides (master page load event if it is on a master page).  Check to see if the user IsAuthenticated and then based on that conditional statement set the provider of the sitemapdatasource to a different provider in the web.config which points to a sitemap file for authenticated, as well as anonymous.  It's a cleaner way then coding to remove items.  Just my opinion.

Another solution, code free, is to use authorization, where you define who can view individual pages; you can do this per user, or preferably, per role. If you then enable SecurityTrimming on the site map provider, the nodes that a user isn't authorised for will be automatically removed from the site map before display.

See the QuickStarts at http://quickstarts.asp.net/QuickStartv20/aspnet/doc/navigation/default.aspx for more.


it works! Here is my code now.

 

protected void Menu1_MenuItemDataBound(object sender, MenuEventArgs e)
    {
        {
            foreach (char f in e.Item.Text)
            {
                if (e.Item.Text == "Student Verification")
                {
                    try
                    {
                        myMenuItem = e.Item;
                        myMenuItem.Text = "It Worked";
                        //Menu1.Items.Remove(myMenuItem);
                        if (e.Item.Parent != null)
                        {
                            e.Item.Parent.ChildItems.Remove(e.Item);
                        }


                    }
                    catch (Exception ex)
                    {
                        string exstring = Convert.ToString(ex);
                    }
                }


            }
       }
}


 

[RESOLVED] Can't see TreeView from code-behind code page

I have an aspx page with a TreeView control named TreeView1.  in the Page_Load method I am trying to collapse all nodes except for the current node.  I used this code in the Page_Load method:

TreeView1.CollapseAllNodes();
TreeView1.SelectedNode.Expand();

When I try to run this I get the following error:

CS0103: The name 'TreeView1' does not exist in the current context

I am using a .NET 2.0 website and can't seem to reference controls in my .aspx page from within my code-behind page. I tried adding an instance of the TreeView before my Page_Load method call in the code behind, but, it still doesn't create a reference.  What am I missing?

Assuming you haven't misspelled "TreeView1", it looks to me like your .aspx isn't connected to your code-behind.

I'd try:

  • rebuilding the entire solution
  • closing Visual Studio, rebooting computer [please, don't say it, I know, but sometimes...]
  • excluding the page in question from your solution, and then adding it in as a new item, copying markup and code from old to new

If all that fails, could you please post all your markup and code - the entirel page?  With that, I'll have a better chance at spotting something. 

(It makes things a lot more readable if you use the Insert Code tool. If you need instructions, see my How to use the Forums' "Insert Code" tool. post.) 

I have tried your suggestions and didn't get much further.  I think I am missing something a little less complex than that.  This is a .NET 2.0 site.  When I tried to reference the controls in the code-behind page I used this approach:

TreeView TreeView1 = (TreeView)Page.FindControl("TreeView1");


However, when I tried to use tab completion after typing (TreeView)Page. it would not provide the FindControl method.  Is there something about the project config I need to look at?  I have never had this much difficulty referencing code from the code-behind.

FindControl executes at run-time, and should only be used for dynamically created controls, like those inside ItemTemplates, etc.

Assuming that you've created TreeView1 using basic markup, you should be able to replace the above line with this "TreeView TreeView1 = this.TreeView1;".   Better yet, you should be able to refer directly to this.TreeView1 wherever you need to.

If this doesn't help, would you mind posting all your relevant markup and code?

The following page doesn't specifically look for TreeView1, but, it's the same problem.  I cannot see controls from the code-behind.  Here is the .aspx code:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="locked_batches.aspx.cs" Inherits="Environments_Model_locked_batches" Src="~/Environments/Model/locked_batches.aspx.cs" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="../../Stylesheets/default.css" rel="Stylesheet" />
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div id="top"><span class="fiserv">eFichency</span> Reference</div>
        <div id="preferences">
            <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
                onselectedindexchanged="DropDownList1_SelectedIndexChanged"></asp:DropDownList>
        </div>
        <div id="content">
            <table>
                <tr>
                    <td>
                        <asp:SiteMapDataSource ID="SiteMapDataSource" runat="server" />
                        <asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource"
                            ImageSet="Msdn" NodeIndent="10">
                            <HoverNodeStyle BackColor="#CCCCCC" BorderColor="#888888" BorderStyle="Solid"
                                Font-Underline="True" />
                            <NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black"
                                HorizontalPadding="5px" NodeSpacing="1px" VerticalPadding="2px" />
                            <ParentNodeStyle Font-Bold="False" />
                            <SelectedNodeStyle BackColor="White" BorderColor="#888888" BorderStyle="Solid"
                                BorderWidth="1px" Font-Underline="False" HorizontalPadding="3px"
                                VerticalPadding="1px" />
                        </asp:TreeView>
                    </td>
                    <td>
			            Find below information on locked batches.<br/><br/>
                        <asp:Label ID="LabelCount" runat="server" Text="The record count is: "></asp:Label><br /><br />
                        <asp:SqlDataSource ID="sqlDataSource" runat="server"
                            SelectCommand="SELECT [AppID], [BatchID], [UserBatchName], [LastEventDate], [Message], [LockedUserID] FROM [Batch] WHERE (([CurrentEventTypeID] = @CurrentEventTypeID) AND ([Received] = @Received))"
                            connectionString="<%$ ConnectionStrings:ModelFOTNIndexConnectionString %>"
                            onselected="SqlDataSource_Selected">
                            <SelectParameters>
                                <asp:Parameter DefaultValue="10" Name="CurrentEventTypeID" Type="Int32" />
                                <asp:Parameter DefaultValue="2" Name="Received" Type="Int32" />
                            </SelectParameters>
                        </asp:SqlDataSource>
                        <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
                            AllowSorting="True" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None"
                            BorderWidth="1px" CellPadding="4" DataSourceID="SqlDataSource"
                            ForeColor="Black" GridLines="Vertical" PageSize="15" Visible="True"
                            onpageindexchanged="GridView1_PageIndexChanged" onsorted="GridView1_Sorted" >
                            <RowStyle BackColor="#F7F7DE" />
                            <EmptyDataTemplate>
                                No records were found.
                            </EmptyDataTemplate>
                            <FooterStyle BackColor="#CCCC99" />
                            <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
                            <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
                            <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
                            <AlternatingRowStyle BackColor="White" />
                        </asp:GridView>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    </form>
</body>
</html>


And, here is the code-behind:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

public partial class Environments_Model_locked_batches : System.Web.UI.Page
{
		protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DropDownList1.DataSource = IndexDataSource(sqlDataSource);
            DropDownList1.DataBind();
            DropDownList1.Items.Insert(0, "Choose a filter string");
        }
    }

    protected ArrayList IndexDataSource(SqlDataSource sqlDataSource)
    {
        ArrayList indexArrayList = new ArrayList();
        DataTable indexDataTable = new DataTable();
        DataView indexDataView = new DataView();

        indexDataView = (DataView)sqlDataSource.Select(DataSourceSelectArguments.Empty);
        indexDataTable = indexDataView.ToTable();

        foreach (DataRow dataRow in indexDataTable.Rows)
        {
            string[] rowIndex = (dataRow["UserBatchName"].ToString()).Split(' ');
            foreach (string word in rowIndex)
            {
                if (!indexArrayList.Contains(word))
                {
                    indexArrayList.Add(word);
                }
            }
        }

        indexArrayList.Sort();

        return indexArrayList;
    }

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (DropDownList1.SelectedValue == "Choose a filter string")
        {
            GridView1.Visible = true;
            GridView1.DataBind();
        }
        else
        {
            sqlDataSource.SelectParameters.Clear();
            sqlDataSource.SelectParameters.Add("UserBatchName", DropDownList1.SelectedValue);
            sqlDataSource.SelectCommand = "SELECT [AppID], [BatchID], [UserBatchName], [LastEventDate], [Message], [LockedUserID] FROM [Batch] WHERE (([CurrentEventTypeID] = @CurrentEventTypeID) AND ([Received] = @Received) OR (UserBatchName LIKE '% ' + @UserBatchName) OR (UserBatchName LIKE @UserBatchName + ' %') OR (UserBatchName LIKE '% ' + @UserBatchName + ' %') OR (UserBatchName = @UserBatchName))";
            GridView1.DataBind();
        }
    }

    protected void GridView1_PageIndexChanged(object sender, EventArgs e)
    {
        if (DropDownList1.SelectedValue == "Choose a filter string")
        {
            GridView1.Visible = true;
            GridView1.DataBind();
        }
        else
        {
            sqlDataSource.SelectParameters.Clear();
            sqlDataSource.SelectParameters.Add("UserBatchName", DropDownList1.SelectedValue);
            sqlDataSource.SelectCommand = "SELECT [AppID], [BatchID], [UserBatchName], [LastEventDate], [Message], [LockedUserID] FROM [Batch] WHERE (([CurrentEventTypeID] = @CurrentEventTypeID) AND ([Received] = @Received) OR (UserBatchName LIKE '% ' + @UserBatchName) OR (UserBatchName LIKE @UserBatchName + ' %') OR (UserBatchName LIKE '% ' + @UserBatchName + ' %') OR (UserBatchName = @UserBatchName))";
            GridView1.DataBind();
        }
    }

    protected void GridView1_Sorted(object sender, EventArgs e)
    {
        if (DropDownList1.SelectedValue == "Choose a filter string")
        {
            GridView1.Visible = true;
            GridView1.DataBind();
        }
        else
        {
            sqlDataSource.SelectParameters.Clear();
            sqlDataSource.SelectParameters.Add("UserBatchName", DropDownList1.SelectedValue);
            sqlDataSource.SelectCommand = "SELECT [AppID], [BatchID], [UserBatchName], [LastEventDate], [Message], [LockedUserID] FROM [Batch] WHERE (([CurrentEventTypeID] = @CurrentEventTypeID) AND ([Received] = @Received) OR (UserBatchName LIKE '% ' + @UserBatchName) OR (UserBatchName LIKE @UserBatchName + ' %') OR (UserBatchName LIKE '% ' + @UserBatchName + ' %') OR (UserBatchName = @UserBatchName))";
            GridView1.DataBind();
        }
    }
    protected void SqlDataSource_Selected(object sender, SqlDataSourceStatusEventArgs e)
    {
        if (DropDownList1.SelectedValue == "Choose a filter string")
        {
            LabelCount.Text = "The record count for all records is: " + e.AffectedRows.ToString();
        }
        else
        {
            LabelCount.Text = "The record count for " + DropDownList1.SelectedValue + " is: " + e.AffectedRows.ToString();
        }

        if (e.Exception != null)
        {
            LabelCount.Visible = false;
            GridView1.EmptyDataText = e.Exception.Message;
        }
    }
}


When I try to run the page, I get this:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Compilation Error 
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS0103: The name 'DropDownList1' does not exist in the current context

Source Error:

 

Line 15:         if (!IsPostBack)
Line 16:         {
Line 17:             DropDownList1.DataSource = IndexDataSource(sqlDataSource);
Line 18:             DropDownList1.DataBind();
Line 19:             DropDownList1.Items.Insert(0, "Choose a filter string");
 

Source File: c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs    Line: 17 



Show Detailed Compiler Output:


c:\windows\system32\inetsrv> "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe" /t:library /utf8output /R:"C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.WorkflowServices\3.5.0.0__31bf3856ad364e35\System.WorkflowServices.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Mobile\2.0.0.0__b03f5f7f11d50a3a\System.Web.Mobile.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Runtime.Serialization\3.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.IdentityModel\3.0.0.0__b77a5c561934e089\System.IdentityModel.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.ServiceModel\3.0.0.0__b77a5c561934e089\System.ServiceModel.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.ServiceModel.Web\3.5.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /out:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\f3c5e0e5\97ac95d6\App_Web_locked_batches.aspx.cs.d4225d1c.bewrivva.dll" /debug- /optimize+ /w:4 /nowarn:1659;1699;1701  "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\f3c5e0e5\97ac95d6\App_Web_locked_batches.aspx.cs.d4225d1c.bewrivva.0.cs" "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\f3c5e0e5\97ac95d6\App_Web_locked_batches.aspx.cs.d4225d1c.bewrivva.1.cs"


Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.3053
for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
Copyright (C) Microsoft Corporation 2001-2005. All rights reserved.

c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(17,13): error CS0103: The name 'DropDownList1' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(17,56): error CS0103: The name 'sqlDataSource' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(18,13): error CS0103: The name 'DropDownList1' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(19,13): error CS0103: The name 'DropDownList1' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(51,13): error CS0103: The name 'DropDownList1' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(53,13): error CS0103: The name 'GridView1' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(54,13): error CS0103: The name 'GridView1' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(58,13): error CS0103: The name 'sqlDataSource' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(59,13): error CS0103: The name 'sqlDataSource' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(59,65): error CS0103: The name 'DropDownList1' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(60,13): error CS0103: The name 'sqlDataSource' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(61,13): error CS0103: The name 'GridView1' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(67,13): error CS0103: The name 'DropDownList1' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(69,13): error CS0103: The name 'GridView1' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(70,13): error CS0103: The name 'GridView1' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(74,13): error CS0103: The name 'sqlDataSource' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(75,13): error CS0103: The name 'sqlDataSource' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(75,65): error CS0103: The name 'DropDownList1' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(76,13): error CS0103: The name 'sqlDataSource' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(77,13): error CS0103: The name 'GridView1' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(83,13): error CS0103: The name 'DropDownList1' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(85,13): error CS0103: The name 'GridView1' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(86,13): error CS0103: The name 'GridView1' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(90,13): error CS0103: The name 'sqlDataSource' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(91,13): error CS0103: The name 'sqlDataSource' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(91,65): error CS0103: The name 'DropDownList1' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(92,13): error CS0103: The name 'sqlDataSource' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(93,13): error CS0103: The name 'GridView1' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(98,13): error CS0103: The name 'DropDownList1' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(100,13): error CS0103: The name 'LabelCount' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(104,13): error CS0103: The name 'LabelCount' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(104,57): error CS0103: The name 'DropDownList1' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(109,13): error CS0103: The name 'LabelCount' does not exist in the current context
c:\Inetpub\wwwroot\reference\Environments\Model\locked_batches.aspx.cs(110,13): error CS0103: The name 'GridView1' does not exist in the current context

 



Show Complete Compilation Source:


Line 1:    using System;
Line 2:    using System.Collections;
Line 3:    using System.Collections.Generic;
Line 4:    using System.Data;
Line 5:    using System.Data.SqlClient;
Line 6:    using System.Web;
Line 7:    using System.Web.UI;
Line 8:    using System.Web.UI.HtmlControls;
Line 9:    using System.Web.UI.WebControls;
Line 10:   
Line 11:   public partial class Environments_Model_locked_batches : System.Web.UI.Page
Line 12:   {
Line 13:   		protected void Page_Load(object sender, EventArgs e)
Line 14:       {
Line 15:           if (!IsPostBack)
Line 16:           {
Line 17:               DropDownList1.DataSource = IndexDataSource(sqlDataSource);
Line 18:               DropDownList1.DataBind();
Line 19:               DropDownList1.Items.Insert(0, "Choose a filter string");
Line 20:           }
Line 21:       }
Line 22:   
Line 23:       protected ArrayList IndexDataSource(SqlDataSource sqlDataSource)
Line 24:       {
Line 25:           ArrayList indexArrayList = new ArrayList();
Line 26:           DataTable indexDataTable = new DataTable();
Line 27:           DataView indexDataView = new DataView();
Line 28:   
Line 29:           indexDataView = (DataView)sqlDataSource.Select(DataSourceSelectArguments.Empty);
Line 30:           indexDataTable = indexDataView.ToTable();
Line 31:   
Line 32:           foreach (DataRow dataRow in indexDataTable.Rows)
Line 33:           {
Line 34:               string[] rowIndex = (dataRow["UserBatchName"].ToString()).Split(' ');
Line 35:               foreach (string word in rowIndex)
Line 36:               {
Line 37:                   if (!indexArrayList.Contains(word))
Line 38:                   {
Line 39:                       indexArrayList.Add(word);
Line 40:                   }
Line 41:               }
Line 42:           }
Line 43:   
Line 44:           indexArrayList.Sort();
Line 45:   
Line 46:           return indexArrayList;
Line 47:       }
Line 48:   
Line 49:       protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
Line 50:       {
Line 51:           if (DropDownList1.SelectedValue == "Choose a filter string")
Line 52:           {
Line 53:               GridView1.Visible = true;
Line 54:               GridView1.DataBind();
Line 55:           }
Line 56:           else
Line 57:           {
Line 58:               sqlDataSource.SelectParameters.Clear();
Line 59:               sqlDataSource.SelectParameters.Add("UserBatchName", DropDownList1.SelectedValue);
Line 60:               sqlDataSource.SelectCommand = "SELECT [AppID], [BatchID], [UserBatchName], [LastEventDate], [Message], [LockedUserID] FROM [Batch] WHERE (([CurrentEventTypeID] = @CurrentEventTypeID) AND ([Received] = @Received) OR (UserBatchName LIKE '% ' + @UserBatchName) OR (UserBatchName LIKE @UserBatchName + ' %') OR (UserBatchName LIKE '% ' + @UserBatchName + ' %') OR (UserBatchName = @UserBatchName))";
Line 61:               GridView1.DataBind();
Line 62:           }
Line 63:       }
Line 64:   
Line 65:       protected void GridView1_PageIndexChanged(object sender, EventArgs e)
Line 66:       {
Line 67:           if (DropDownList1.SelectedValue == "Choose a filter string")
Line 68:           {
Line 69:               GridView1.Visible = true;
Line 70:               GridView1.DataBind();
Line 71:           }
Line 72:           else
Line 73:           {
Line 74:               sqlDataSource.SelectParameters.Clear();
Line 75:               sqlDataSource.SelectParameters.Add("UserBatchName", DropDownList1.SelectedValue);
Line 76:               sqlDataSource.SelectCommand = "SELECT [AppID], [BatchID], [UserBatchName], [LastEventDate], [Message], [LockedUserID] FROM [Batch] WHERE (([CurrentEventTypeID] = @CurrentEventTypeID) AND ([Received] = @Received) OR (UserBatchName LIKE '% ' + @UserBatchName) OR (UserBatchName LIKE @UserBatchName + ' %') OR (UserBatchName LIKE '% ' + @UserBatchName + ' %') OR (UserBatchName = @UserBatchName))";
Line 77:               GridView1.DataBind();
Line 78:           }
Line 79:       }
Line 80:   
Line 81:       protected void GridView1_Sorted(object sender, EventArgs e)
Line 82:       {
Line 83:           if (DropDownList1.SelectedValue == "Choose a filter string")
Line 84:           {
Line 85:               GridView1.Visible = true;
Line 86:               GridView1.DataBind();
Line 87:           }
Line 88:           else
Line 89:           {
Line 90:               sqlDataSource.SelectParameters.Clear();
Line 91:               sqlDataSource.SelectParameters.Add("UserBatchName", DropDownList1.SelectedValue);
Line 92:               sqlDataSource.SelectCommand = "SELECT [AppID], [BatchID], [UserBatchName], [LastEventDate], [Message], [LockedUserID] FROM [Batch] WHERE (([CurrentEventTypeID] = @CurrentEventTypeID) AND ([Received] = @Received) OR (UserBatchName LIKE '% ' + @UserBatchName) OR (UserBatchName LIKE @UserBatchName + ' %') OR (UserBatchName LIKE '% ' + @UserBatchName + ' %') OR (UserBatchName = @UserBatchName))";
Line 93:               GridView1.DataBind();
Line 94:           }
Line 95:       }
Line 96:       protected void SqlDataSource_Selected(object sender, SqlDataSourceStatusEventArgs e)
Line 97:       {
Line 98:           if (DropDownList1.SelectedValue == "Choose a filter string")
Line 99:           {
Line 100:              LabelCount.Text = "The record count for all records is: " + e.AffectedRows.ToString();
Line 101:          }
Line 102:          else
Line 103:          {
Line 104:              LabelCount.Text = "The record count for " + DropDownList1.SelectedValue + " is: " + e.AffectedRows.ToString();
Line 105:          }
Line 106:  
Line 107:          if (e.Exception != null)
Line 108:          {
Line 109:              LabelCount.Visible = false;
Line 110:              GridView1.EmptyDataText = e.Exception.Message;
Line 111:          }
Line 112:      }
Line 113:  }
 




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3615; ASP.NET Version:2.0.50727.3618 


Anywhere I have a control from the .aspx page, it shows the same error.  This is just the first control reference it encounters.

Will,

I must admit I'm pretty stumped.  Somehow, the .aspx and the code-behind aren't finding each other.

There's one thing I notice about your page that's different from mine.  In the <@Page> directive, you have a "Src=" attribute that my pages never have.  According to this MSDN article:

"You can use the Src attribute to link build providers to the page. For more information, see the BuildProvider class. Also, in versions of ASP.NET prior to 2.0, the Src attribute was used as an alternative way to link a code-behind file to a page. In ASP.NET 2.0, the preferred approach to linking a code-behind source file to a page is to use the Inherits attribute to specify a class, along with the CodeFile attribute to specify the path to the source file for the class."

That's something I've never needed, and I suggest that you try removing it.

I am beginning to this machine has some gremlins.  I use the Src attribute as a workaround to compiler issue.  It was saying it couldn't find the .cs file.  When I added the Src attribute, which I had never used either, it worked fine.  I am positive I have the site set to ASP.NET 2.0 in IIS, so, I don't think it's a version issue.  If I can't get it figured out soon, I might request a different box.  There are all sorts of weird things on this machine that make no sense.  I just wanted to be sure I wasn't overlooking something obvious.

Will,

Did you try taking the Src back out?

Your CodeFile attribute is where you should resolve the "couldn't find the .cs file" issue.  Based on what's in your <@Page> directive, your code must be in a file named "locked_batches.aspx.cs" which must be in the same directory as the .aspx.

Let me know.

 

AHA! I found another possible fix.

The same MSDN page says:

"[CodeFile] is used for Web site projects. The CodeBehind attribute is used for Web application projects."

In other words, if you are creating a Web Application (as opposed to a Web Site) you should change "CodeFile" to "CodeBehind" in your <@Page>.

asp repeater with horizontal menu and sub menu

Hi,

I'm so confused. I'm trying to do an horizontal menu and on the top right. Just two buttons will be there.

Then passing other thus A and B to have the submenu in a div below which appear. This div should be a block in my header.

Something which take the whole page on the larger.

 

I m just so confused about it


My sitemap is like that :

 

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" enableLocalization="true">
  <siteMapNode url="~/Default.aspx" title="$resources:Menu, ttHome" description="$resources:Menu, descHome" metaKeywords="$resources:Menu, mKeyHome" metaDesc="$resources:Menu, mDescHome" pageTitle="$resources:Menu, pgttHome">

    <siteMapNode visible="true" url="~/Test/default.aspx" title="$resources:Menu, ttPhy" description="$resources:Menu, descPhy" metaKeywords="$resources:Menu, mKeyPhy" metaDesc="$resources:Menu, mDescPhy" pageTitle="$resources:Menu, pgttPhy" width="$resources:Menu, widtPhy" pageHeader="$resources:Menu, pgHdPhy">
      <siteMapNode visible="true" url="~/Test/Definition.aspx" title="$resources:Menu, ttDefinition" description="$resources:Menu, descDefinition" metaKeywords="$resources:Menu, mKeyDefinition" metaDesc="$resources:Menu, mDescDefinition" pageTitle="$resources:Menu, pgttDefinition" width="$resources:Menu, widtDefinition" pageHeader="$resources:Menu, pgHdDefinition"/>
      <siteMapNode visible="true" url="~/Test/Objectives.aspx" title="$resources:Menu, ttObjectives" description="$resources:Menu, descObjectives" metaKeywords="$resources:Menu, mKeyObjectives" metaDesc="$resources:Menu, mDescObjectives" pageTitle="$resources:Menu, pgttObjectives" width="$resources:Menu, widtObjectives" pageHeader="$resources:Menu, pgHdObjectives"/>
      <siteMapNode visible="true" url="~/Test/DataCollection.aspx" title="$resources:Menu, ttDataColl" description="$resources:Menu, descDataColl" metaKeywords="$resources:Menu, mKeyDataColl" metaDesc="$resources:Menu, mDescDataColl" pageTitle="$resources:Menu, pgttDataColl" width="$resources:Menu, widtDataColl" pageHeader="$resources:Menu, pgHdDataColl"/>
      <siteMapNode visible="true" url="~/Test/Participation.aspx" title="$resources:Menu, ttParticipation" description="$resources:Menu, descParticipation" metaKeywords="$resources:Menu, mKeyParticipation" metaDesc="$resources:Menu, mDescParticipation" pageTitle="$resources:Menu, pgttParticipation" width="$resources:Menu, widtParticipation" pageHeader="$resources:Menu, pgHdParticipation"/>
      <siteMapNode visible="true" url="~/Test/Contributing.aspx" title="$resources:Menu, ttContributing" description="$resources:Menu, descContributing" metaKeywords="$resources:Menu, mKeyContributing" metaDesc="$resources:Menu, mDescContributing" pageTitle="$resources:Menu, pgttContributing" width="$resources:Menu, widtContributing" pageHeader="$resources:Menu, pgHdContributing"/>
      <siteMapNode visible="true" url="~/Test/Enrollment.aspx" title="$resources:Menu, ttEnrollment" description="$resources:Menu, descEnrollment" metaKeywords="$resources:Menu, mKeyEnrollment" metaDesc="$resources:Menu, mDescEnrollment" pageTitle="$resources:Menu, pgttEnrollment" width="$resources:Menu, widtEnrollment" pageHeader="$resources:Menu, pgHdEnrollment"/>
      <siteMapNode visible="true" url="~/Test/Form.aspx" title="$resources:Menu, ttForm" description="$resources:Menu, descForm" metaKeywords="$resources:Menu, mKeyForm" metaDesc="$resources:Menu, mDescForm" pageTitle="$resources:Menu, pgttForm" width="$resources:Menu, widtForm" pageHeader="$resources:Menu, pgHdForm"/>
    </siteMapNode>

    <siteMapNode visible="true" url="~/Try/default.aspx" title="$resources:Menu, ttPat" description="$resources:Menu, descPat" metaKeywords="$resources:Menu, mKeyPat" metaDesc="$resources:Menu, mDescPat" pageTitle="$resources:Menu, pgttPat" width="$resources:Menu, widtPat" pageHeader="$resources:Menu, pgHdPat">
      <siteMapNode visible="true" url="~/Try/Definition.aspx" title="$resources:Menu, ttDefinitionPat" description="$resources:Menu, descDefinitionPat" metaKeywords="$resources:Menu, mKeyDefinitionPat" metaDesc="$resources:Menu, mDescDefinitionPat" pageTitle="$resources:Menu, pgttDefinitionPat" width="$resources:Menu, widtDefinitionPat" pageHeader="$resources:Menu, pgHdDefinitionPat"/>
      <siteMapNode visible="true" url="~/Try/Participation.aspx" title="$resources:Menu, ttParticipationPat" description="$resources:Menu, descParticipationPat" metaKeywords="$resources:Menu, mKeyParticipationPat" metaDesc="$resources:Menu, mDescParticipationPat" pageTitle="$resources:Menu, pgttParticipationPat" width="$resources:Menu, widtParticipationPat" pageHeader="$resources:Menu, pgHdParticipationPat"/>
    </siteMapNode>

    
    <!--<siteMapNode visible="$resources:Menu, visiSiteMp" url="/Utility/sitemap.aspx" title="$resources:Menu, ttSiteMp" description="$resources:Menu, descSiteMp" metaKeywords="$resources:Menu, mKeySiteMp" metaDesc="$resources:Menu, mDescSiteMp" pageTitle="$resources:Menu, pgttSiteMp" pageHeader="$resources:Menu, pgHdSiteMp" />-->

  </siteMapNode>
</siteMap>

 

 

My Css is like that :



/* a hack so that IE5.5 faulty box model is corrected */
/* * html #wrapNavTop a, * html #wrapNavTop a:visited { width: 139px; w\idth: 139px;} */


#wrapNavTop li {
  float: left;/* width: 139px; */
  position: relative;
  text-align: center;
  width: auto;
}
/* style the links for the top level */
#wrapNavTop table {
  border-collapse: collapse;
  left: 0;
  position: absolute;
  top: 0;
}
/* style the second level links */


/* hack to correct IE5.5 faulty box model */
/* * html #wrapNavTop { width: 980px; w\idth: 980px; } */
/* remove all the bullets, borders and padding from the default list styling */
#wrapNavTop ul li ul li.hasLevel3 a:active, #wrapNavTop ul li ul li.hasLevel3 a:hover {
  background: #fff url(     '/styles/images/nav/nav.pixmap.gif' ) no-repeat 50% -105px;
  color: #000;
  font-weight: normal;
  text-decoration: none;
}
/* style the top level hover */
#wrapNavTop ul li ul li.hasLevel3 a:link, #wrapNavTop ul li ul li.hasLevel3 a:visited {
  background: #fff url(     '/styles/images/nav/nav.pixmap.gif' ) no-repeat 50% -70px;
  color: #535353;
  font-weight: normal;
}
/* style the second level hover if third level exists */
#wrapNavTop ul li ul li.hasLevel3 li a:link, #wrapNavTop ul li ul li.hasLevel3 li a:visited {
  background: #fff none;
  color: #535353;
  font-weight: normal;
}
/* style the second level hover if third level exists */
#wrapNavTop ul li ul li.hasLevel3 ul li.seperator a {
  background: transparent;
  color: #d8d8d8;
  font-size: 1px;
  height: 1px;
  line-height: 1px;
  margin: 0 auto;
  padding: 0;
  width: 139px;
}
/*------------------------------------------*/
#wrapNavTop ul li ul li.hasLevel3 ul li.seperator, #wrapNavTop ul li.selected ul li.hasLevel3 ul li.seperator {
  background: transparent;
  color: #fff;
  font-size: 1px;
  height: 1px;
  line-height: 1px;
}
#wrapNavTop ul li ul li.seperator a, #wrapNavTop ul li.selected ul li.seperator a {
  background: #d4d4d4;
  color: #d8d8d8;
  font-size: 1px;
  height: 1px;
  line-height: 1px;
  margin: 0 auto;
  padding: 0;
  width: 139px;
}
#wrapNavTop ul li ul li.seperator, #wrapNavTop ul li.selected ul li.seperator {
  background: transparent url(     '/styles/images/nav/nav.pixmap.gif' ) no-repeat 50% -35px;
  color: #fff;
  font-size: 1px;
  height: 1px;
  line-height: 1px;
}
#wrapNavTop ul li.last ul ul {
  left: -153px;
}
/* style the table so that it takes no part in the layout - required for IE to work */
#wrapNavTop ul li.selected a, #wrapNavTop ul li.selected a:link, #wrapNavTop ul li.selected a:visited
{
	background-position: #cc0000 none;
	background-color: #CACACA;
	color: #FFFFFF;
	font-weight: normal;
}
#wrapNavTop ul li.selected a:active, #wrapNavTop ul li.selected a:hover
{
	background-position: #CCCCCC;
	background-color: #cc0000;
	color: #FFFFFF;
	font-weight: normal;
}
/* style the second level hover if third level exists */
#wrapNavTop ul li.selected a:hover ul, #wrapNavTop ul li:hover ul, #wrapNavTop ul a:hover ul, #wrapNavTop ul:hover ul:hover ul {
  display: block;
  visibility: visible;
}
/* keep the third level hidden when you hover on first level list OR link */
#wrapNavTop ul li.selected ul li a, #wrapNavTop ul li.selected ul li a:link, #wrapNavTop ul li.selected ul li a:visited {
  background: #fff;
  color: #535353;
  font-weight: normal;
}

#wrapNavTop ul li.seperator {
  background: #BE4249;
  font-size: 1px;
  height: 30px;
  line-height: 1px;
}
#wrapNavTop ul ul
{
	/*visibility: hidden;*/
	background: #fff;
	border: 1px solid #d6d6d6;
	border-top: 0 none;
	display: none;
	height: auto;
	left: 40;
	position: absolute;
	top: 80px; /* distance sub menu */
	width: 153px;
}
/* another hack for IE5.5 */
/* * html #wrapNavTop ul ul {top:40px; top:40px;} */
/* position the third level flyout menu */
#wrapNavTop ul ul {
/* width: 139px; */
  z-index: 1000;
}
/* float the list to make it horizontal and a relative positon so that you can control the dropdown menu positon */
#wrapNavTop ul ul a, #wrapNavTop ul ul a:visited {
  background: transparent;
  color: #000;
  height: auto;
  line-height: 16px;
  width: 139px;
}
#wrapNavTop ul ul a.drop, #wrapNavTop ul ul a.drop:visited {
  background: #a71930;
  color: #fff;
  font-weight: normal;
}
/* style the second level hover */
#wrapNavTop ul ul a.drop:hover {
  background: #f4f4f4;
  color: #5d5d5d;
}
#wrapNavTop ul ul li {
  background: #fff;
  color: #5d5d5d;
  text-align: left;
  width: 153px;
}
/* style the second level background */
#wrapNavTop ul ul li a, #wrapNavTop ul ul li a:link, #wrapNavTop ul ul li a:visited {
  background: transparent;
  color: #535353;
  font-weight: normal;
  height: auto;
  margin: 0 auto;
  min-height: 23px;
  padding: 8px 6px 4px 6px;
  width: 139px;
  width: 127px;
}

/* style the second level hover if third level exists */
#wrapNavTop ul ul ul {
  border: 1px solid #d6d6d6;
  left: 153px;
  top: 0;
  width: 153px;
}
/* position the third level flyout menu for a left flyout */
#wrapNavTop ul ul ul {
  left: 153px;
  top: -1px;
  width: 153px;
}
/* position the third level flyout menu to the right */
#wrapNavTop ul ul ul a, #wrapNavTop ul ul ul a:visited {
  background: #fff;
}
/* style the third level hover */
#wrapNavTop ul ul ul a:hover {
  background: #E8E8E8;
}
/* hide the sub levels and give them a positon absolute so that they take up no room */
#wrapNavTop ul ul:hover > a.drop {
  background: #E8E8E9;
  color: #535353;
}
#wrapNavTop UL
{
	list-style-type: none;
	list-style-image: none;
	height: 15px;
}
#wrapNavTop UL LI {
	 FLOAT: right; PADDING-TOP: 0px
}

#wrapNavTop UL LI A {
	PADDING-BOTTOM: 12px; LINE-HEIGHT: 1.2em; MARGIN: 0px; PADDING-LEFT: 16px; PADDING-RIGHT: 16px; DISPLAY: block; COLOR: #959595; FONT-SIZE: 14px; TEXT-DECORATION: none; 
	PADDING-TOP: 40px
}
#wrapNavTop UL LI.active A {
	BACKGROUND-COLOR: #cc0000; COLOR: #fff
}
	

#wrapNavTop UL LI A:hover
{
	background-color: #cc0000;
	color: #FFFFFF; /*padding-bottom: 0px;
	margin: 0px;
	padding-left: 0px;
	padding-right: 8px;
	float: right;
	padding-top: 0px;*/
}

#wrapNavTop ul {
  float: right;
  list-style-type: none;
  margin: 0;
  padding: 0;
  width: auto;
  z-index: 1000;
}
#wrapNavTop ul li a {
  height: 30px;
  text-decoration: none;
}
#wrapNavTop ul li ul li a {
  height: auto;
  text-decoration: none;
}

#wrapNavTop ul ul li a:active, #wrapNavTop ul ul li a:hover, #wrapNavTop ul li.selected ul li a:active, #wrapNavTop ul li.selected ul li a:hover, #wrapNavTop ul li ul li.hasLevel3 li a:active, #wrapNavTop ul li ul li.hasLevel3 li a:hover
{
	background-position: 50% -35px;
	background: #C0C0C0 url(../styles/images/nav/nav.pixmap.gif) no-repeat 50% -35px;
	color: #FFFFFF;
	font-weight: normal;
	text-decoration: none;
}

#topPan ul.dropdown{list-style-type: none; width:580px; height:22px; position:absolute; top:59px; right:60px; display:block;}
#topPan ul.dropdown li{float:left; width:79px; height:22px; }
#topPan ul.dropdown li a{display:block; width:79px;background:url(images/vertical-dot.gif) 100% 0 no-repeat #fff; color:#3E3E3E; font-size:11px; text-decoration:none; text-align:center; line-height:22px;} 
#topPan ul.dropdown li a:hover{text-decoration:none; background:url(images/vertical-dot.gif) 100% 0 no-repeat #fff; color:#7C7900;}

 

 

 

And my code in my master page is like :

      <div id="wrapNavTop">
                    <asp:SiteMapDataSource ID="smdsNavTop" runat="server" StartingNodeUrl="Default.aspx"
                        ShowStartingNode="False" SiteMapProvider="sitemapNavTop" />
                <asp:Repeater runat="server" ID="repNavTop" DataSourceID="smdsNavTop">
                    <HeaderTemplate>
                        <ul id="navTop">
                            <%-- <li class="flg"></li>  --%>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <%# (isVisible((SiteMapNode)Container.DataItem) ? "<li class=\"seperator\">&nbsp;</li>" : "")%>
                        <%# UtlFuncs.isActiveNode((SiteMapNode)Container.DataItem) && (isVisible((SiteMapNode)Container.DataItem)) ? "<li class='selected'>" : (isVisible((SiteMapNode)Container.DataItem) ? "<li>" : "")%>
                        <asp:HyperLink ID="navTop" runat='server' NavigateUrl='<%# Server.UrlPathEncode(Eval("Url", "{0}")) %>'
                            ToolTip='<%# Server.HtmlDecode(Eval("Title", "{0}")) %>' Visible='<%# (isVisible((SiteMapNode)Container.DataItem)) %>'
                            Width='<%# Convert.ToInt32(Eval("[width]")) %>'>
                            <%# Server.HtmlEncode(Eval("Description", "{0}"))%>
                        </asp:HyperLink>
                        <asp:Repeater runat="server" ID="repNavTopL2" DataSource="<%# ((SiteMapNode) Container.DataItem).ChildNodes %>"
                            Visible="<%# ((SiteMapNode) Container.DataItem).ChildNodes.Count == 0 ? false : true %>">
                            <HeaderTemplate>
                                <ul>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <%# (isVisible((SiteMapNode)Container.DataItem) && (Container.ItemIndex > 0) ? "<li class=\"seperator\">&nbsp;</li>" : "")%>
                                <li id="Li1" runat="server" visible='<%# (isVisible((SiteMapNode)Container.DataItem)) %>'>
                                    <asp:HyperLink ID="navTopL2" runat='server' NavigateUrl='<%# Server.UrlPathEncode(Eval("Url", "{0}")) %>'
                                        ToolTip='<%# Server.HtmlDecode(Eval("Title", "{0}")) %>' Visible='<%# (isVisible((SiteMapNode)Container.DataItem)) %>'>
                                        <%# Server.HtmlEncode(Eval("Description", "{0}"))%>
                                    </asp:HyperLink>
                                </li>
                            </ItemTemplate>
                            <FooterTemplate></ul> </FooterTemplate>
                        </asp:Repeater>
                        <%# (isVisible((SiteMapNode)Container.DataItem) ? "</li>" : "")%>
                    </ItemTemplate>
                    <FooterTemplate></ul> </FooterTemplate>
                </asp:Repeater>
            </div>

 

Thanks a lot for your help,

I don't know who can help me on this .... or know where can i find an exemple on that ... but ive no idea.

 

 

 

 

 

 

 

 

 

[RESOLVED] How to get SiteMapPath1's Current FullPath Displaying Text

question seems simple but I couldnt find a way.
so How can I get SiteMapPath1's Current Displaying Text ?

It renders to page display,the full path from root to current .I can see at page like this "HomePage>>Blah>>Blah" but I cannot get this text.

should I write a for loop to get parent node till to rootnode ? or is there an ready property that I can get this displayingtext value ?

(thanks)

ofsure I did this functionality via a primitive recurrency loop function.

what if I bump this question as covering its orginal may help some ?
I  am missing a property something like this ?:

a=SiteMapPath1.RenderedText;

?


Hi,

hcetiner

question seems simple but I couldnt find a way.
so How can I get SiteMapPath1's Current Displaying Text ?

If you use SiteMapPath and conjunction with the SiteMapDataSource or SiteMapPath, you can get the current node by SiteMap.CurrentNode 

Like:

private void Page_Load(object sender, System.EventArgs e)
{
    // Examine the CurrentNode, and navigate the SiteMap relative to it.
    Response.Write(SiteMap.CurrentNode.Title + "<br />");
    Response.Write("<font COLOR='red'>" + SiteMap.CurrentNode.Url + "</font><br />");

}

About SiteMap class, Simply speaking, it is a container for a hierarchical collection of SiteMapNode objects. You can check this link:

http://msdn.microsoft.com/en-us/library/system.web.sitemap.aspx

Hope this can help you.

the SiteMapPath doesn't expose this as a single piece of text. The way it works it out is to start at the current mode and use ParentNode upwards until ParentNode is null.

If you just want the text then you could wrap the SiteMapPath in another control, such as a server div and extract the InnerHtml, or a Panel and get the inner controls.

need WISWIG (What I see What I Get).Need Full path.the displayingtext