Hello,
I am building a MVC program. When I test the menu in the View:
<telerik:RadMenu ID="RadMenu1" runat="server">
<Items>
<telerik:RadMenuItem runat="server" PostBack="False" Text="M1-1"
NavigateUrl="~/home/show?p1=10" >
</telerik:RadMenuItem>
</Items>
</telerik:RadMenu>
it works. But in my case, I need to change the parameter value "p1" in run-time, depending on the combination of some previous user's inputs.
Ideally, if I can use some variables in the codes such as:
... NavigateUrl="~/home/show?p1=<%= Session['magic_number'] %>" ...
this will solve the issue. However, this code runs into parser error.
I wonder if there is any solution or workaround to address this situation. Many thanks.
I am building a MVC program. When I test the menu in the View:
<telerik:RadMenu ID="RadMenu1" runat="server">
<Items>
<telerik:RadMenuItem runat="server" PostBack="False" Text="M1-1"
NavigateUrl="~/home/show?p1=10" >
</telerik:RadMenuItem>
</Items>
</telerik:RadMenu>
it works. But in my case, I need to change the parameter value "p1" in run-time, depending on the combination of some previous user's inputs.
Ideally, if I can use some variables in the codes such as:
... NavigateUrl="~/home/show?p1=<%= Session['magic_number'] %>" ...
this will solve the issue. However, this code runs into parser error.
I wonder if there is any solution or workaround to address this situation. Many thanks.
5 Answers, 1 is accepted
0
Cori
Top achievements
Rank 2
answered on 07 Jan 2011, 03:34 PM
Hello Nim,
To bind the NavigateUrl, you would do something like this:
NavigateUrl='<%# String.Format("~/home/show?p1={0}",Session["magic_number"]) %>'
I hope that helps.
To bind the NavigateUrl, you would do something like this:
NavigateUrl='<%# String.Format("~/home/show?p1={0}",Session["magic_number"]) %>'
I hope that helps.
0
Nim
Top achievements
Rank 1
answered on 07 Jan 2011, 06:49 PM
Hello,
When I run the following test in the View:
------
<% Session["magic_number"] = "2"; %>
<p>
Testing - make sure it stores the value: <%= Session["magic_number"] %>
</p>
<telerik:RadMenu ID="RadMenu1" runat="server">
<Items>
<telerik:RadMenuItem runat="server" PostBack="False" Text="M1-1"
FocusedCssClass="" SelectedCssClass=""
NavigateUrl='<%# String.Format("~/home/show?p1={0}",Session["magic_number"]) %>' >
</telerik:RadMenuItem>
</Items>
</telerik:RadMenu>
------
the generated path returns "#" instead of "~/home/show?p1=2". Am I missing something?
Thank you!
When I run the following test in the View:
------
<% Session["magic_number"] = "2"; %>
<p>
Testing - make sure it stores the value: <%= Session["magic_number"] %>
</p>
<telerik:RadMenu ID="RadMenu1" runat="server">
<Items>
<telerik:RadMenuItem runat="server" PostBack="False" Text="M1-1"
FocusedCssClass="" SelectedCssClass=""
NavigateUrl='<%# String.Format("~/home/show?p1={0}",Session["magic_number"]) %>' >
</telerik:RadMenuItem>
</Items>
</telerik:RadMenu>
------
the generated path returns "#" instead of "~/home/show?p1=2". Am I missing something?
Thank you!
0
Hello Nim,
Please note that ASP.NET and ASP.NET MVC are two completely different frameworks.
Let me suggest you use the Telerik Menu for ASP.NET MVC in your MVC application.
You can find the key features of this control demonstrated here.
Kind regards,
Kalina
the Telerik team
Please note that ASP.NET and ASP.NET MVC are two completely different frameworks.
Let me suggest you use the Telerik Menu for ASP.NET MVC in your MVC application.
You can find the key features of this control demonstrated here.
Kind regards,
Kalina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Paul X
Top achievements
Rank 1
answered on 10 Apr 2011, 06:50 AM
<
telerik:RadMenuItem runat="server" Value="Home" Text="Home" NavigateUrl='<%# String.Format("~/home/show?p1={0}","hello") %>'>
trying to set url at runtime but produces no output just a #..any reason?
ie
<li class="rmItem rmFirst">
<a class="rmLink rmRootLink rmSelected" href="#">
<span class="rmText">Home</span>
</a>
</li>
0
Calleigh
Top achievements
Rank 1
answered on 14 Apr 2011, 05:29 PM
You can use the Menu for ASP.NET MVC instead of implementing the RadMenu for ASP.NET AJAX in your MVC application.
http://demos.telerik.com/aspnet-mvc/menu
http://demos.telerik.com/aspnet-mvc/menu