Visual Studio .NET - using # in asp.net2.0 menu control navigateurl property

Asked By shekhar kumar on 20-Nov-08 06:11 AM
Hi I am using menu control in 2005.
The problem is
I have to navigate the menu on a page particular line(Book mark).
what I am doing is in navigate url I am using # symbol for the bookmark name.
But it is giving error.
Can anyone help me.


re - Web Star replied to shekhar kumar on 20-Nov-08 06:20 AM

use as follows

1        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
2            If Not IsPostBack Then
3                PopulateMenu()
4            End If
6        End Sub
8        Sub PopulateMenu()
9            Dim dst As System.Data.DataSet = GetMenuData()
10           For Each masterRow As System.Data.DataRow In dst.Tables("shopping_category").Rows()
11               Dim masterItem As New MenuItem(masterRow("category").ToString())
12               Menu1.Items.Add(masterItem)
13               For Each childRow As System.Data.DataRow In masterRow.GetChildRows("Children")
14                   Dim childItem As New MenuItem(childRow("order_title").ToString())
15                   masterItem.ChildItems.Add(childItem)
16               Next
17           Next
18       End Sub
19       Function GetMenuData() As System.Data.DataSet
20           Dim con As New System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.AppSettings("con"))
21           Dim dadCats As New _
22             System.Data.SqlClient.SqlDataAdapter("SELECT [category], primary_key FROM shopping_ca=", con)
23           Dim dadProducts As New _
24           System.Data.SqlClient.SqlDataAdapter("SELECT [category id], [primary_key], [order_title] FROM shopping_it", con)
25           Dim dst As New System.Data.DataSet()
26           dadCats.Fill(dst, "shopping_category")
27           dadProducts.Fill(dst, "shopping_items")
28           dst.Relations.Add("Children", _
29               dst.Tables("shopping_category").Columns("primary_key"), _
30               dst.Tables("shopping_items").Columns("Category ID"))
31           Return dst
32       End Function

This is the front end..

1        <asp:Menu
2            id="Menu1" Orientation="Vertical"
3            Runat="Server" staticdisplaylevels="2" StaticSubMenuIndent="0px" Width="180"  >
5        <LevelMenuItemStyles>
6            <asp:MenuItemStyle CssClass="menuheader" ForeColor="#ff6603" />
7            <asp:MenuItemStyle cssclass="subheader" ForeColor="#0669ff" Font-Underline="true"/>
8        </LevelMenuItemStyles>
9        <StaticHoverStyle forecolor="#000000" />
10       <StaticSelectedStyle ForeColor="#000000" Font-Bold="true" Font-Underline="false" />
11       </asp:Menu>

Thanks - shekhar kumar replied to Web Star on 20-Nov-08 06:27 AM

But my problem is this that
when I am using navigateurl property of menu control
and in that navigate url I have to use a hash (#) symbol for going on the next page(book mark)
but after using # sign it is giving an exception.

Can I use Hash symbol (#) in navigate url property.

Thanks once again

NavigateUrl property - mv ark replied to shekhar kumar on 20-Nov-08 06:58 AM

Any valid anchor point or bookmark within a document can be specified in the NavigateUrl property as per this reliable link -

Can you show us what URL you are placing & what error  you get?
Re :: Using # in NavigateUrl Property of menu control - SP replied to shekhar kumar on 20-Nov-08 07:01 AM

Give it a try use the full url with your website name in the navigateurl property.

like ""

Hope this helps.

And also let me know the error. What error it is giving?

Thanks - shekhar kumar replied to mv ark on 20-Nov-08 07:08 AM
I don't know why it was not working yesterday. It's working fine now. Thanks a lot
re - Web Star replied to shekhar kumar on 20-Nov-08 07:10 AM
u need to just backslash "\" for consiter special char like \#