We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

define root url in menu item

Hi,

I've this menu:

           <ej:Menu ID="menuPrincipal" runat="server" CssClass="menuPrincipal">
                    <Items>
                        <ej:MenuItem Text="Inicio" Url="~/Default.aspx" ></ej:MenuItem>
                        <ej:MenuItem Text="Control Operaciones">
                            <Items>
                                <ej:MenuItem Text="Electricidad">
                                    <Items>
                                        <ej:MenuItem Text="Informe Diario" Url="~/ControlOperaciones/Electricidad/InformeDiario.aspx"/>
                                        <ej:MenuItem Text="Informe Semanal" Url="~/ControlOperaciones/Electricidad/InformeSemanal.aspx" />
                                    </Items>
                                </ej:MenuItem>
                                <ej:MenuItem Text="Gas">
                                    <Items>
                                        <ej:MenuItem Text="Informe Diario" Url="~/ControlOperaciones/Gas/InformeDiario.aspx" />
                                        <ej:MenuItem Text="Informe Semanal" Url="~/ControlOperaciones/Gas/InformeSemanal.aspx" />
                                    </Items>
                                </ej:MenuItem>
                            </Items>
                        </ej:MenuItem>
                        <ej:MenuItem Text="Gestión Campañas"></ej:MenuItem>
                        <ej:MenuItem Text="Informes Mensuales Data G&E"></ej:MenuItem>
                        <ej:MenuItem Text="Informes Resultados Control Calidad"></ej:MenuItem>
                        <ej:MenuItem Text="Indicadores LMyO" Url="~/IndicadoresLMyO/Default.aspx"></ej:MenuItem>
                    </Items>
                </ej:Menu>

But, the urls navigation don't work, for example, if I'm in "/ControlOperaciones/Electricidad/InformeSemanal.aspx"  page, if a click on Inicio menu item I go to this page:

http://localhost:63615/ControlOperaciones/Electricidad/~/Default.aspx

How can i set the root value correctly?

17 Replies

KC Kasithangam C Syncfusion Team September 22, 2015 09:30 AM UTC

Hi Manolo,

On analyzing your code, we found that, there is URL path doesn’t provide properly in the menu item. This is the cause of the issue while click on menu item it doesn’t navigate to the proper page. To resolve this issue, we need to remove the symbol ~/ in the provided path url. Please find the code for the same,

<code>

<ej:Menu ID="menuPrincipal" runat="server" CssClass="menuPrincipal">

                    <Items>

                        <ej:MenuItem Text="Inicio" Url="Default.aspx" ></ej:MenuItem>

                        <ej:MenuItem Text="Control Operaciones">

                            <Items>

                                <ej:MenuItem Text="Electricidad">

                                    <Items>

                                        <ej:MenuItem Text="Informe Diario" Url="ControlOperaciones/Electricidad/InformeDiario.aspx"/>

                                        <ej:MenuItem Text="Informe Semanal" Url="ControlOperaciones/Electricidad/InformeSemanal.aspx" />

                                    </Items>

                                </ej:MenuItem>

                                <ej:MenuItem Text="Gas">

                                    <Items>

                                        <ej:MenuItem Text="Informe Diario" Url="ControlOperaciones/Gas/InformeDiario.aspx" />

                                        <ej:MenuItem Text="Informe Semanal" Url="ControlOperaciones/Gas/InformeSemanal.aspx" />

                                    </Items>

                                </ej:MenuItem>

                            </Items>

                        </ej:MenuItem>

                        <ej:MenuItem Text="Gestión Campañas"></ej:MenuItem>

                        <ej:MenuItem Text="Informes Mensuales Data G&E"></ej:MenuItem>

                        <ej:MenuItem Text="Informes Resultados Control Calidad"></ej:MenuItem>

                        <ej:MenuItem Text="Indicadores LMyO" Url="IndicadoresLMyO/Default.aspx"></ej:MenuItem>

                    </Items>

                </ej:Menu>

</code>
We have prepared the sample based on this and please refer to the following sample:

Sample: Sample

Please let us know if you have further query.                                

Regards,
Kasithangam



MA Manolo September 23, 2015 02:32 PM UTC

Hi Kasithangam,

My menu is defined on MasterPage, so, from any page, I must navigate to others.

In your example, the menu control is only in Button.aspx, but this is not my case.

When I stay, for example, in page "ControlOperaciones/Electricidad/InformeSemanal" and I want go to other page, the redirectios is wrong.

I attach other example

Attachment: SampleButton_276c7073.zip


KC Kasithangam C Syncfusion Team September 24, 2015 10:35 AM UTC

Hi Manolo,

The cause of the issue “url doesn’t navigate when render menu control in site master page” is our Menu control scripts reference path doesn’t loaded propery while click menu item to navigating other page.To resolve this issue, remove the custom scripts and css references in site master page and please add the below code in web.config file.

<code>
[Web.Config]


<appSettings>

    <add key="LoadEJResourcesFromAssembly" value="true" />

    <add key="EJResources" value="jsrender:true;jqueryeasing:true;globalize:true;themes:true;" />
  </appSettings>
</code>

While enabling LoadEJResourcesFromAssembly and EJResoures app key settings it will include our necessary script and CSS files as embedded resource from the EJ.Web assembly itself.
Also, we need to modify the URL path in menu control based on the folder structure and please find the code for same:

<code>

<ej:Menu ID="menuPrincipal" runat="server" CssClass="menuPrincipal">

                    <Items>

                        <ej:MenuItem Text="Inicio" Url="../../Default.aspx" ></ej:MenuItem>

                        <ej:MenuItem Text="Control Operaciones">

                            <Items>

                                <ej:MenuItem Text="Electricidad">

                                    <Items>

                                        <ej:MenuItem Text="Informe Diario" Url="../../ControlOperaciones/Electricidad/InformeDiario.aspx"/>

                                        <ej:MenuItem Text="Informe Semanal" Url="../../ControlOperaciones/Electricidad/InformeSemanal.aspx" />

                                    </Items>

                                </ej:MenuItem>

                                <ej:MenuItem Text="Gas">

                                    <Items>

                                        <ej:MenuItem Text="Informe Diario" Url="../../ControlOperaciones/Gas/InformeDiario.aspx" />

                                        <ej:MenuItem Text="Informe Semanal" Url="../../ControlOperaciones/Gas/InformeSemanal.aspx" />

                                    </Items>

                                </ej:MenuItem>

                            </Items>

                        </ej:MenuItem>

                        <ej:MenuItem Text="Gestión Campañas"></ej:MenuItem>

                        <ej:MenuItem Text="Informes Mensuales Data G&E"></ej:MenuItem>

                        <ej:MenuItem Text="Informes Resultados Control Calidad"></ej:MenuItem>

                        <ej:MenuItem Text="Indicadores LMyO" Url="../../IndicadoresLMyO/Default.aspx"></ej:MenuItem>

                    </Items>
                </ej:Menu>
</code>

Now, when you click on the menu item the corresponding page navigates properly.We have modified the sample based on this and please refer to the following sample:

Sample: Sample

Please let us know if you have further query.                                

Regards,

Kasithangam



MA Manolo September 24, 2015 10:48 AM UTC

Ok! Thanks a lot!


KC Kasithangam C Syncfusion Team September 25, 2015 04:37 AM UTC

Hi Manolo,
Thanks for your update. Please get back to us if you have further queries. We will be happy to help you out.

Regards,
Kasithangam



MA Manolo October 23, 2015 06:04 PM UTC

Hi again,

I've a problem when I put the project into a external server.

if I've this adress:

http://serverxxxxxx.es/WebSite_xxxxx/Default

when I want use a menu item, it redirects wrong, setting the menu item with url "../../XXXX" it redirect to similar adress:

http://serverxxxxxx.es/ControlOperaciones/Electricidad/InformeDiario.aspx

the string "WebSite_xxxx" is removed.

So.... Can I set the tag runat=server into menu items? So setting the url "~/ControlOperaciones/Electricidad/InformeDiario.aspx", I'm sure that it works fine.

Also, I will need hide or show menu items in function users profile, and I'll do it in code behind and I need set this property.


Thanks



SS Saranya Sivakumar Syncfusion Team October 26, 2015 10:35 AM UTC

Hi Manolo,

We can set the tag runat=”server” for the menu items in order to access the corresponding item in server side. So we can set runat=”server” for the menu items as shown in the following code snippet.

<code>

<ej:Menu ID="menuPrincipal" runat="server" CssClass="menuPrincipal">

                    <Items>

                        <ej:MenuItem runat="server" Text="Inicio" Url="../../Default.aspx"></ej:MenuItem>

                        <ej:MenuItem runat="server" Text="Control Operaciones">

                            <Items>

                                <ej:MenuItem runat="server"  Text="Electricidad">

                                    <Items>

                                        <ej:MenuItem runat="server"  Text="Informe Diario" Url="../../ControlOperaciones/Electricidad/InformeDiario.aspx"/>

                                        <ej:MenuItem runat="server"  Text="Informe Semanal" Url="../../ControlOperaciones/Electricidad/InformeSemanal.aspx"/>

                                    </Items>

                                </ej:MenuItem>

                    </Items>
                </ej:Menu>


</code>

Please let us know if you have any other queries.

Regards,

Saranya.S



MA Manolo October 26, 2015 03:32 PM UTC

in tag

<ej:MenuItem>

Visual Studio 2015 intellisense can not recognize tag runat="server"

And, if I set this tag and the url similar at this:

<ej:MenuItem runat="server" Text="Informe Semanal Electricidad" Url="~/ControlOperaciones/MedidasIndustriales/InformeSemanalElectricidad.aspx" />

When I click, it cannot redirect fine. The wrong redirect url:

http://localhost:55773/Administracion/ControlOperaciones/~/ControlOperaciones/MedidasIndustriales/InformeSemanalElectricidad.aspx


SS Saranya Sivakumar Syncfusion Team October 28, 2015 09:56 AM UTC

Hi Manolo,

We regret for the inconvenience caused,

You can still use runat server for the menu items even though it is not shown in intellisence. Also we suggest use to use Page.ResolveClientUrl to maintain the path accordingly. While hosting it in server it possess the corresponding path. Please refer the below code snippet for more details.

<code>

<ej:Menu ID="menuPrincipal" runat="server" CssClass="menuPrincipal">

                    <Items>

                        <ej:MenuItem Id="menuitem1" Text="Inicio" Url="<%= Page.ResolveClientUrl('~/Default.aspx')%>" ></ej:MenuItem>

                        <ej:MenuItem Text="Control Operaciones">

                            <Items>

                                <ej:MenuItem Text="Electricidad">

                                    <Items>

                                        <ej:MenuItem Text="Informe Diario" Url="<%= Page.ResolveClientUrl('~/ControlOperaciones/Electricidad/InformeDiario.aspx')%>"/>

                                        <ej:MenuItem Text="Informe Semanal" Url="<%= Page.ResolveClientUrl('~/ControlOperaciones/Electricidad/InformeSemanal.aspx')%>" />

                                    </Items>

                                </ej:MenuItem>

                                <ej:MenuItem Text="Gas">

                                    <Items>

                                        <ej:MenuItem Text="Informe Diario" Url="<%= Page.ResolveClientUrl('~/ControlOperaciones/Gas/InformeDiario.aspx')%>" />

                                        <ej:MenuItem Text="Informe Semanal" Url="<%= Page.ResolveClientUrl('~/ControlOperaciones/Gas/InformeSemanal.aspx')%>" />

                                    </Items>

                                </ej:MenuItem>

                            </Items>

                        </ej:MenuItem>

                        <ej:MenuItem Text="Gestión Campañas"></ej:MenuItem>

                        <ej:MenuItem Text="Informes Mensuales Data G&E"></ej:MenuItem>

                        <ej:MenuItem Text="Informes Resultados Control Calidad"></ej:MenuItem>

                        <ej:MenuItem Text="Indicadores LMyO" Url="<%= Page.ResolveClientUrl('~/IndicadoresLMyO/Default.aspx')%>"></ej:MenuItem>

                    </Items>

                </ej:Menu>

</code>

For your convienience we have modified the sample based on hosting in server and the same can be downloaded from the following location.

http://www.syncfusion.com/downloads/support/forum/120497/ze/MenuUrl1247599311

Kindly check with the sample. If still you face the problem then please share us the online link which you have hosted in the server. Also if possible please share us the entire sample in which we can able to reproduce the error. This will be helpful for us to serve you better.

Regards,

Saranya.S



MA Manolo October 28, 2015 12:32 PM UTC

Hi,

I upload your last attached project into a test server.

The url is:

http://www.testmenu.somee.com/website/button.aspx

If I click on first menu item, Inicio:

<ej:MenuItem Text="Inicio" Url="../../Default.aspx" ></ej:MenuItem>

it redirects into http://www.testmenu.somee.com/Default.aspx, with no website folder, so, it's wrong.

If I click on second menu, the item inicio

<ej:MenuItem Id="menuitem1" Text="Inicio" Url="<%= Page.ResolveClientUrl('~/Default.aspx')%>" ></ej:MenuItem>

It also redirects wrong

http://www.testmenu.somee.com/website/%3C%=%20Page.ResolveClientUrl%28'~/Default.aspx'%29%%3E

if you need the user and passworsd say me.

Thanks




SS Saranya Sivakumar Syncfusion Team October 29, 2015 05:52 PM UTC

Hi Manolo,

We would like to let you know that, we have to specify the URL path according to your folder structure to which the Menu item should get navigated. In your update we have found that you are having a folder named “website” and you have been navigating to it. So you have to mention the URL as shown in the following code snippet.

<code>

<ej:Menu ID="menuPrincipal" runat="server" CssClass="menuPrincipal">

                    <Items>

                        <ej:MenuItem Id="menuitem1" Text="Inicio" Url="<%= Page.ResolveClientUrl('~/website/Default.aspx')%>" ></ej:MenuItem>

                        <ej:MenuItem Text="Control Operaciones"></ej:MenuItem>

                     <%-- Your Menu Items Here --%>

</Items>

 </ej:Menu>


</code>

So Kindly set the path according to your folder structure. If still you face the problem then please share us your hosted sample along with the folder structure and share us your username and password. This will be helpful for us to serve you better.

Regards,

Saranya.S



MA Manolo October 30, 2015 08:05 AM UTC

Sorry, I can't set the url path fine.

In this page:

https://somee.com/default.aspx

in control panel I put the project.

For access

user: manolocapdevila
password: Syncfusion123

Inside, in managed products ->WebSites ->TestMenu.Somee.com ->Applications there is a file explorer with a folder WebSite and inside there is the test project.



Thanks


MS Muralishankar Sundaram Syncfusion Team November 3, 2015 01:44 PM UTC

 Hi Manola,

Thanks for your update,

In order to solve the url navigation issue, We suggest you to use the Page.ResolveClientUrl() method in the code-behind. Please find the sample code snippet bellow:

<code>
[ASPX]

<ej:Menu ID="menuPrincipal" runat="server" CssClass="menuPrincipal">

                    <Items>

                        <ej:MenuItem Text="Inicio" Url="~/Default.aspx" ></ej:MenuItem>

                        <ej:MenuItem Text="Control Operaciones">

                            <Items>

                                <ej:MenuItem Text="Electricidad">

                                    <Items>

                                        <ej:MenuItem Text="Informe Diario" Url="~/ControlOperaciones/Electricidad/InformeDiario.aspx"/>

                                        <ej:MenuItem Text="Informe Semanal" Url="~/ControlOperaciones/Electricidad/InformeSemanal.aspx" />

                                    </Items>

                                </ej:MenuItem>

                                <ej:MenuItem Text="Gas">

                                    <Items>

                                        <ej:MenuItem Text="Informe Diario" Url="~/ControlOperaciones/Gas/InformeDiario.aspx" />

                                        <ej:MenuItem Text="Informe Semanal" Url="~/ControlOperaciones/Gas/InformeSemanal.aspx" />

                                    </Items>

                                </ej:MenuItem>

                            </Items>

                        </ej:MenuItem>

                        <ej:MenuItem Text="Gestión Campañas"></ej:MenuItem>

                        <ej:MenuItem Text="Informes Mensuales Data G&E"></ej:MenuItem>

                        <ej:MenuItem Text="Informes Resultados Control Calidad"></ej:MenuItem>

                        <ej:MenuItem Text="Indicadores LMyO" Url="~/IndicadoresLMyO/Default.aspx"></ej:MenuItem>

                    </Items>
                </ej:Menu>

[cs]

protected void Page_Load(object sender, EventArgs e)

        {

            for (int index = 0; index < menuPrincipal.Items.Count; index++)

            {

                if (!string.IsNullOrEmpty(menuPrincipal.Items[index].Url))

                    menuPrincipal.Items[index].Url = Page.ResolveClientUrl(menuPrincipal.Items[index].Url);

                for (int index1 = 0; index1 < menuPrincipal.Items[index].Items.Count; index1++)

                {

                    if (!string.IsNullOrEmpty(menuPrincipal.Items[index].Items[index1].Url))

                        menuPrincipal.Items[index].Items[index1].Url = Page.ResolveClientUrl(menuPrincipal.Items[index].Items[index1].Url);

                    for (int index2 = 0; index2 < menuPrincipal.Items[index].Items[index1].Items.Count; index2++)

                    {

                        if (!string.IsNullOrEmpty(menuPrincipal.Items[index].Items[index1].Items[index2].Url))

                            menuPrincipal.Items[index].Items[index1].Items[index2].Url = Page.ResolveClientUrl(menuPrincipal.Items[index].Items[index1].Items[index2].Url);

                    }

                }


            }

               
        }
</code>

We have prepared the Menu –URL navigation sample and its available in a below link:
http://www.syncfusion.com/downloads/support/forum/120497/ze/Sample_Menu1524654363


Please let us know if you have any other queries.

Regards,
Muralishankar



MA Manolo November 3, 2015 02:12 PM UTC

Hi,

Thanks for your update!

but another question, is possible fix this in a future update?

Thank you again!


ES Ezhil S Syncfusion Team November 4, 2015 11:02 AM UTC

Hi Manola,

We have logged defect report regarding the Menu control Url property. A support incident to track the status of this defect has been created under your account. Please log on to our support website to check for further updates

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents

Please let us know if you have any questions.

Best,
Ezhil S


MA Manolo November 4, 2015 11:03 AM UTC

Ok,

Thanks a lot!


AP Arun Palaniyandi Syncfusion Team November 5, 2015 04:28 AM UTC

Hi Manola,

Thanks for your update.

We are glad that provided solution helped you to resolve the issue at your end. 

Let us know if you need further assistance.

Regards,
Arun P

Loader.
Live Chat Icon For mobile
Up arrow icon