Welcome Guest Search | Active Topics | Sign In | Register

Menu control - Navigate URL does not work Options
Luiz Ferreira
Posted: Friday, May 29, 2009 3:47:51 PM
Rank: Member
Groups: Member

Joined: 12/4/2008
Posts: 17
Hi

I am using the menu control (Red Tabs) and using a SQL table to build the menu tabs ( just one level). I am binding the eob.menu to a dataset. When I run the code the menu shows correctly but when I click on any tab it does not go anywhere. It says on the default page. Can someone help. Thanks

Here is my table:

Group_name navigate_URL Server_flag
Home default.aspx True
TabA taba.aspx True
TabB tabb.aspx True

Here is my code:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim cmd As String
Dim myDS As New DataSet
Dim cs As String = System.Configuration.ConfigurationManager.AppSettings.Item("Sales")
Dim mycon As New SqlClient.SqlConnection(cs)
'****Server_flag is a Bit field value True or false
cmd = "Select Group_name,navigateUrl,Server_flag from web_helpdesk_groups where menu_display = 'True' Order by menu_display_order"
Dim myDA As New SqlClient.SqlDataAdapter(cmd, mycon)
Try
mycon.Open()
Catch ex As Exception
Dim x As String = ex.ToString
x = x
End Try
myDA.Fill(myDS, "groups")

Menu1.DataSource = myDS.Tables("groups")
Menu1.DataFields = "Group_name"

'Bind the "NavigateURL" column in the table to "NavigateUrl" property.
'******
Dim binding As New EO.Web.DataBinding()
binding.DataField = "NavigateURL"
binding.Property = "NavigateUrl"

' Add this MenuDataBinding class into the group's binding collection.
Menu1.Bindings.Add(binding)
'********

'Bind the "Server_flag" column in the table to "RaisesServerEvent" property of each item
'******
Dim binding2 As New EO.Web.DataBinding()
binding.DataField = "Server_flag"
binding.Property = "RaisesServerEvent"

' Add this MenuDataBinding class into the group's binding
' collection.
Menu1.Bindings.Add(binding2)
'*************
Menu1.DataBind()

mycon.Close()
end sub
eo_support
Posted: Friday, May 29, 2009 3:53:27 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

I can see that you have "Navigate_URL" in your database, but "NavigateURL" in your DataBinding object. They must match.

Thanks!
Luiz Ferreira
Posted: Friday, May 29, 2009 4:06:03 PM
Rank: Member
Groups: Member

Joined: 12/4/2008
Posts: 17
Hi Thanks for the quick reply

The names match. I just typed wrong when I did the posting. If you look at the code, they match.
Thanks
eo_support
Posted: Friday, May 29, 2009 4:54:26 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Your code looks fine to us. In fact we tested the following page and it works fine:

Code: HTML/ASPX
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Page Language="VB" %>
<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>
<%@ Import Namespace="System.Data" %>

<script runat="server">

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        Menu1.DataSource = CreateDataTable()
        Menu1.DataFields = "group_name"

        Dim binding As EO.Web.DataBinding
        binding = New EO.Web.DataBinding()
        binding.DataField = "NavigateURL"
        binding.Property = "NavigateUrl"
        Menu1.Bindings.Add(binding)

        Menu1.DataBind()
    End Sub
    
    Private Function CreateDataTable() As DataTable
        Dim table As DataTable
        Dim col As DataColumn
        
        table = New DataTable()
        col = New DataColumn("group_name", Type.GetType("System.String"))
        table.Columns.Add(col)
        col = New DataColumn("navigateUrl", Type.GetType("System.String"))
        table.Columns.Add(col)
        col = New DataColumn("server_flag", Type.GetType("System.Boolean"))
        table.Columns.Add(col)

        table.Rows.Add("Home", "default.aspx", True)
        table.Rows.Add("TabA", "tata.aspx", True)
        table.Rows.Add("TabB", "tabb.aspx", True)

        Return table
        
    End Function
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <eo:Menu runat="server" ID="Menu1">
        </eo:Menu>
    </form>
</body>
</html>


Our code is slightly different than yours on:

1. It does not have binding for RaisesServerEvent. RaisesServerEvent does not support data binding (because it is not a simple booleaning value). If you wish to set RaisesServerEvent based on the value in your database, you can handle ItemDataBound event and then set from there by code. ItemDataBound event is called once for each item;

2. We create the DataTable directly from code. This is because we do not have your database. There is no difference from the Menu point of view regarding this. It takes a DataTable and it does not care how that DataTable was created;

Please try the test page and see if it works for you. If it works for you, I would expect the problem to be related to your data or other elements in your page.

Thanks!
Luiz Ferreira
Posted: Friday, May 29, 2009 5:22:33 PM
Rank: Member
Groups: Member

Joined: 12/4/2008
Posts: 17
Hi,

When I eliminate the binding for the RaisesServerEvent it worked. It navigates to the URL

Now how do I set RaisesServerEvent to True in the code?

Private Sub Menu1_ItemDataBound(ByVal sender As Object, ByVal e As EO.Web.NavigationItemEventArgs) Handles Menu1.ItemDataBound
'** this gives me an error
e.MenuItem.RaisesServerEvent = True
'** this also gives me an error
Dim v As Boolean = True
e.MenuItem.RaisesServerEvent = v

End Sub


Thanks
eo_support
Posted: Friday, May 29, 2009 5:34:15 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Just to let you know, you will not be able to use RaisesServerEvent and NavigateUrl at the same time. We did not mention this in our earlier post because when both are correctly set, NavigateUrl suppose to take a higher priority and work. So it contradicts your case where NavigateUrl was not working.

RaisesServerEvent and NavigateUrl never works at the same time because RaisesServerEvent always post back (HTTP POST) to the same page (because that's where your event handler is), and NavigateUrl always navigate (HTTP GET) to another page.

If you wish the menu to post back first, then redirect to another page, you can bind your DB NavigateUrl field into the menu's Value property (instead of NavigateUrl property). You would then handle the menu's ItemClick event and call Response.Redirect inside your ItemClick event:

Code: Visual Basic.NET
Response.Redirect(e.MenuItem.Value)


You can use the following code to set RaisesServerEvent with code:

Code: Visual Basic.NET
e.MenuItem.RaisesServerEvent = EO.Web.NullableBool.True


Hope this helps.

Thanks!
Luiz Ferreira
Posted: Friday, May 29, 2009 5:38:14 PM
Rank: Member
Groups: Member

Joined: 12/4/2008
Posts: 17
Perfect explanation! Thank you very much.
eo_support
Posted: Friday, May 29, 2009 6:00:41 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Not a problem. Feel free to let us know if you have any more questions.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.