This question is locked. New answers and comments are not allowed.
Wolfgang Maier
Top achievements
Rank 1
Wolfgang Maier
asked on 09 Dec 2009, 02:55 PM
Hi,
I try the first time MVC and Telerik-Extensions.
How can I add the Area in the Action-Method of a menu-item?
The routing works, because when I put the url '/Music/Home/Index' the correct view is displayed:
Music => Area
Home => Controller
Index => Action
And how can i add the link to the Telerik-Menuitem?
thx.
Wolfgang
Graz, Austria, Europe
I try the first time MVC and Telerik-Extensions.
How can I add the Area in the Action-Method of a menu-item?
The routing works, because when I put the url '/Music/Home/Index' the correct view is displayed:
Music => Area
Home => Controller
Index => Action
And how can i add the link to the Telerik-Menuitem?
thx.
Wolfgang
Graz, Austria, Europe
10 Answers, 1 is accepted
0
Hello Wolfgang Maier,
Regards,
Atanas Korchev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
You can try this:
Action("Index", "Home", new { area="Music" } )
Regards,
Atanas Korchev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Wolfgang Maier
Top achievements
Rank 1
answered on 11 Dec 2009, 07:28 AM
Hi Atanas,
thank you for your help.
I have tried as you written the notation of Html.Actionlink:
thank you for your help.
I have tried as you written the notation of Html.Actionlink:
| item.Add().Text("CD-Liste") |
| .ImageUrl("~/Content/Images/Icons/Mvc/Grid.png") |
| .Action("Index", "Home", new { area = "Musik" }); |
but the I got a empty href:
href="#"
0
Hi Wolfgang Maier,
Atanas Korchev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I have attached a sample project showing how to use MVC2 areas with the menu. Please check it out.
I hope this helps,Atanas Korchev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Wolfgang Maier
Top achievements
Rank 1
answered on 11 Dec 2009, 05:54 PM
Hi Atanas,
It has helped, a little.
I can now go to my Musik-area.
After insert the AreaRegistration and adding the namespace for the Musik-Controller in the MapRoute.
But:
Have tried in your example to go to your Test-Area and then go back to home?
All links then have the Test-Area.
The same here.
Wolfgang.
It has helped, a little.
I can now go to my Musik-area.
After insert the AreaRegistration and adding the namespace for the Musik-Controller in the MapRoute.
But:
Have tried in your example to go to your Test-Area and then go back to home?
All links then have the Test-Area.
The same here.
Wolfgang.
0
Wolfgang Maier
Top achievements
Rank 1
answered on 11 Dec 2009, 06:03 PM
Sorry Atanas,
I was too fast with my first post.
When I insert a empty area to the Home and About - Action, then it works.
Thank you for your help.
Wolfgang.
I was too fast with my first post.
When I insert a empty area to the Home and About - Action, then it works.
Thank you for your help.
Wolfgang.
0
Chuck
Top achievements
Rank 2
answered on 08 May 2010, 08:04 PM
I tried using this project as the basis for using PortableAreas (from the MVC Contrib project) and ran into a slight issue that I was able to reproduce using this solution and linking to the 2010.1.416.235 version of Telerik's MVC DLL.
The problem stems from the fact that, even though I'm navigating to an Area, in GetControllerType when it calls
System.NullReferenceException was unhandled by user code
Message=Object reference not set to an instance of an object.
Source=Telerik.Web.Mvc
StackTrace:
at Telerik.Web.Mvc.Infrastructure.Implementation.AuthorizeAttributeCache.GetAuthorizeAttributes(RequestContext requestContext, String controllerName, String actionName) in C:\Paylocity\Paylocity.Common\Extern\Telerik\Telerik Extensions for ASP.NET MVC\Source\Telerik.Web.Mvc\Infrastructure\Implementation\AuthorizeAttributeCache.cs:line 41
at Telerik.Web.Mvc.Infrastructure.Implementation.ControllerAuthorization.IsAccessibleToUser(RequestContext requestContext, String controllerName, String actionName) in C:\Paylocity\Paylocity.Common\Extern\Telerik\Telerik Extensions for ASP.NET MVC\Source\Telerik.Web.Mvc\Infrastructure\Implementation\ControllerAuthorization.cs:line 57
at Telerik.Web.Mvc.Infrastructure.Implementation.NavigationItemAuthorization.IsAccessibleToUser(RequestContext requestContext, INavigatable navigationItem) in C:\Paylocity\Paylocity.Common\Extern\Telerik\Telerik Extensions for ASP.NET MVC\Source\Telerik.Web.Mvc\Infrastructure\Implementation\NavigationItemAuthorization.cs:line 38
at Telerik.Web.Mvc.UI.NavigatableExtensions.IsAccessible(INavigatable item, INavigationItemAuthorization authorization, ViewContext viewContext) in C:\Paylocity\Paylocity.Common\Extern\Telerik\Telerik Extensions for ASP.NET MVC\Source\Telerik.Web.Mvc\UI\NavigatableExtensions.cs:line 176
at Telerik.Web.Mvc.UI.Menu.WriteItem(MenuItem item, IHtmlNode parentTag, IMenuHtmlBuilder builder) in C:\Paylocity\Paylocity.Common\Extern\Telerik\Telerik Extensions for ASP.NET MVC\Source\Telerik.Web.Mvc\UI\Menu\Menu.cs:line 179
at Telerik.Web.Mvc.UI.Menu.<>c__DisplayClass4.<WriteHtml>b__3(MenuItem item) in C:\Paylocity\Paylocity.Common\Extern\Telerik\Telerik Extensions for ASP.NET MVC\Source\Telerik.Web.Mvc\UI\Menu\Menu.cs:line 164
at Telerik.Web.Mvc.Extensions.EnumerableExtensions.Each[T](IEnumerable`1 instance, Action`1 action) in C:\Paylocity\Paylocity.Common\Extern\Telerik\Telerik Extensions for ASP.NET MVC\Source\Telerik.Web.Mvc\Extensions\EnumerableExtensions.cs:line 63
at Telerik.Web.Mvc.UI.Menu.WriteHtml(HtmlTextWriter writer) in C:\Paylocity\Paylocity.Common\Extern\Telerik\Telerik Extensions for ASP.NET MVC\Source\Telerik.Web.Mvc\UI\Menu\Menu.cs:line 164
at Telerik.Web.Mvc.UI.ViewComponentBase.Render() in C:\Paylocity\Paylocity.Common\Extern\Telerik\Telerik Extensions for ASP.NET MVC\Source\Telerik.Web.Mvc\UI\ViewComponentBase.cs:line 166
at Telerik.Web.Mvc.UI.ViewComponentBuilderBase`2.Render() in C:\Paylocity\Paylocity.Common\Extern\Telerik\Telerik Extensions for ASP.NET MVC\Source\Telerik.Web.Mvc\UI\ViewComponentBuilderBase.cs:line 136
at Telerik.Web.Mvc.UI.ViewComponentBuilderBase`2.ToString() in C:\Paylocity\Paylocity.Common\Extern\Telerik\Telerik Extensions for ASP.NET MVC\Source\Telerik.Web.Mvc\UI\ViewComponentBuilderBase.cs:line 147
at System.Web.HttpWriter.Write(Object obj)
at System.Web.Mvc.ViewPage.SwitchWriter.Write(Object value)
at System.Web.UI.HtmlTextWriter.Write(Object value)
at ASP.views_shared_site_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in c:\Src\TelerikMVCAreasSampleApp\Views\Shared\Site.Master:line 25
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
at System.Web.UI.Control.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
at System.Web.UI.Page.Render(HtmlTextWriter writer)
at System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:
The problem stems from the fact that, even though I'm navigating to an Area, in GetControllerType when it calls
match = GetControllerTypeWithinNamespaces(requestContext.RouteData.Route,controllerName, routeNamespaces);
it is passing Home as the controllerName instead of the PortableArea's controllerName so it can't find it and returns null whenrequestContext.RouteData.DataTokens["UseNamespaceFallback"] is false (the default).
The stack trace is as follows:
System.NullReferenceException was unhandled by user code
Message=Object reference not set to an instance of an object.
Source=Telerik.Web.Mvc
StackTrace:
at Telerik.Web.Mvc.Infrastructure.Implementation.AuthorizeAttributeCache.GetAuthorizeAttributes(RequestContext requestContext, String controllerName, String actionName) in C:\Paylocity\Paylocity.Common\Extern\Telerik\Telerik Extensions for ASP.NET MVC\Source\Telerik.Web.Mvc\Infrastructure\Implementation\AuthorizeAttributeCache.cs:line 41
at Telerik.Web.Mvc.Infrastructure.Implementation.ControllerAuthorization.IsAccessibleToUser(RequestContext requestContext, String controllerName, String actionName) in C:\Paylocity\Paylocity.Common\Extern\Telerik\Telerik Extensions for ASP.NET MVC\Source\Telerik.Web.Mvc\Infrastructure\Implementation\ControllerAuthorization.cs:line 57
at Telerik.Web.Mvc.Infrastructure.Implementation.NavigationItemAuthorization.IsAccessibleToUser(RequestContext requestContext, INavigatable navigationItem) in C:\Paylocity\Paylocity.Common\Extern\Telerik\Telerik Extensions for ASP.NET MVC\Source\Telerik.Web.Mvc\Infrastructure\Implementation\NavigationItemAuthorization.cs:line 38
at Telerik.Web.Mvc.UI.NavigatableExtensions.IsAccessible(INavigatable item, INavigationItemAuthorization authorization, ViewContext viewContext) in C:\Paylocity\Paylocity.Common\Extern\Telerik\Telerik Extensions for ASP.NET MVC\Source\Telerik.Web.Mvc\UI\NavigatableExtensions.cs:line 176
at Telerik.Web.Mvc.UI.Menu.WriteItem(MenuItem item, IHtmlNode parentTag, IMenuHtmlBuilder builder) in C:\Paylocity\Paylocity.Common\Extern\Telerik\Telerik Extensions for ASP.NET MVC\Source\Telerik.Web.Mvc\UI\Menu\Menu.cs:line 179
at Telerik.Web.Mvc.UI.Menu.<>c__DisplayClass4.<WriteHtml>b__3(MenuItem item) in C:\Paylocity\Paylocity.Common\Extern\Telerik\Telerik Extensions for ASP.NET MVC\Source\Telerik.Web.Mvc\UI\Menu\Menu.cs:line 164
at Telerik.Web.Mvc.Extensions.EnumerableExtensions.Each[T](IEnumerable`1 instance, Action`1 action) in C:\Paylocity\Paylocity.Common\Extern\Telerik\Telerik Extensions for ASP.NET MVC\Source\Telerik.Web.Mvc\Extensions\EnumerableExtensions.cs:line 63
at Telerik.Web.Mvc.UI.Menu.WriteHtml(HtmlTextWriter writer) in C:\Paylocity\Paylocity.Common\Extern\Telerik\Telerik Extensions for ASP.NET MVC\Source\Telerik.Web.Mvc\UI\Menu\Menu.cs:line 164
at Telerik.Web.Mvc.UI.ViewComponentBase.Render() in C:\Paylocity\Paylocity.Common\Extern\Telerik\Telerik Extensions for ASP.NET MVC\Source\Telerik.Web.Mvc\UI\ViewComponentBase.cs:line 166
at Telerik.Web.Mvc.UI.ViewComponentBuilderBase`2.Render() in C:\Paylocity\Paylocity.Common\Extern\Telerik\Telerik Extensions for ASP.NET MVC\Source\Telerik.Web.Mvc\UI\ViewComponentBuilderBase.cs:line 136
at Telerik.Web.Mvc.UI.ViewComponentBuilderBase`2.ToString() in C:\Paylocity\Paylocity.Common\Extern\Telerik\Telerik Extensions for ASP.NET MVC\Source\Telerik.Web.Mvc\UI\ViewComponentBuilderBase.cs:line 147
at System.Web.HttpWriter.Write(Object obj)
at System.Web.Mvc.ViewPage.SwitchWriter.Write(Object value)
at System.Web.UI.HtmlTextWriter.Write(Object value)
at ASP.views_shared_site_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in c:\Src\TelerikMVCAreasSampleApp\Views\Shared\Site.Master:line 25
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
at System.Web.UI.Control.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
at System.Web.UI.Page.Render(HtmlTextWriter writer)
at System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:
0
Hello Chuck,
Frankly speaking we have never tested our components with the portable areas from the MvcContrib project. I would appreciate it if you open a support ticket and send us a sample project which demonstrates this problem.
Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Frankly speaking we have never tested our components with the portable areas from the MvcContrib project. I would appreciate it if you open a support ticket and send us a sample project which demonstrates this problem.
Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Clint Tennill
Top achievements
Rank 1
answered on 20 Aug 2010, 07:39 PM
Was there ever any more investigation on the MvcContrib portable areas and the Telerik grid? We have run into the same problem Chuck presented and would like to know if any additional work was done.
0
Chuck
Top achievements
Rank 2
answered on 20 Aug 2010, 07:56 PM
After I created the ticket that was requested in this forum thread, I received confirmation that the problem can be fixed by modifying the source code as follows:
I was also told, after asking, that the check for false.Equals(requestContext.RouteData.DataTokens["UseNamespaceFallback"]) was never needed in the first place.
That change worked for me, and it was supposed to have been checked into their main branch so presumably it should be in the Q2 2010 Beta release available for download (I personally haven't confirmed that yet) and included then Q2 2010 finally ships.
- Open ControllerTypeCache.cs
- Locate the following statement:
if (match != null || false.Equals(requestContext.RouteData.DataTokens["UseNamespaceFallback"])) - Change it to:
if (match != null)
I was also told, after asking, that the check for false.Equals(requestContext.RouteData.DataTokens["UseNamespaceFallback"]) was never needed in the first place.
That change worked for me, and it was supposed to have been checked into their main branch so presumably it should be in the Q2 2010 Beta release available for download (I personally haven't confirmed that yet) and included then Q2 2010 finally ships.
0
Chitrang
Top achievements
Rank 1
answered on 07 Jan 2011, 10:26 PM
Hi Atanas,
Thanks for providing the sample project. It helped me as I am new to MVC as well as using Telerik control. I have one question though, the way you have created the Menu using Telerik control in Site.Master, is it possible to have multi-level menu? If so how do I add the 2nd level? for example lets say if I want to add another item under Area Link or Home how do I do that using the same code?
Thanks in advance!
Thanks & Regards,
Chitrang Golvelker
Thanks for providing the sample project. It helped me as I am new to MVC as well as using Telerik control. I have one question though, the way you have created the Menu using Telerik control in Site.Master, is it possible to have multi-level menu? If so how do I add the 2nd level? for example lets say if I want to add another item under Area Link or Home how do I do that using the same code?
Thanks in advance!
Thanks & Regards,
Chitrang Golvelker