I'm using MVC3 with the Telerik MVC Q3 2010 SP1 controls and I've encountered a road block while using the PanelBar.
I've sucessfully used the Ajax.ActionLink to create a test link and load a partialview into my html. Now i'm trying to make the PanelBar items behave just the same.
So, I'm basically trying to change from something like item.Url = Url.Action(....), and start using a Ajax.ActionLink. (Or something simillar) I've tried all that I could think of to make the Ajax.ActionLink work but nothing seems to do it.
Is this possible or should I capture the client side event and load the content 'manually'?
Thanks for your help,
João Caxaria
7 Answers, 1 is accepted
Sorry, but I don't understand how that project can help me. Maybe I didn't explain my problem as I should:
I have my PanelBar fully complete with all the items I want. Now I want that when a PanelBarItem is clicked, instead of doing a get to the controller, I want a ajax request and replace another div in my page with the partial view that comes back.
If it's of any help, this is my panelbar:
@using Telerik.Web.Mvc.UI;@model IEnumerable<UserMenuItem>@{ Html.Telerik().PanelBar() .Name("PanelBar") .HtmlAttributes(new { style = "width: 300px; float: left; margin-bottom: 30px;" }) .ExpandMode(PanelBarExpandMode.Multiple) .SelectedIndex(0) .BindTo(Model, mappings => { mappings.For<UserMenuItem>(binding => binding .ItemDataBound((item, menuItem) => { item.Text = menuItem.Text; item.ImageUrl = menuItem.Image; if (!string.IsNullOrEmpty(menuItem.Controller)) { item.Url = Url.Action(menuItem.Action, menuItem.Controller, menuItem.Arguments); } }) .Children(rootMenu => rootMenu.Children)); }).Render();}Now, instead of using the item.Url = Url.Action(...) I wanted to somehow use the Ajax.ActionLink(...). Is this possible?
Tthanks for your time,
João Caxaria
I can do a item.ContentUrl but that fills the PanelBar which I don't want to do.
I can do a item.Url butr that just takes me to another page.
I want to do a PartialView into another div on my current page based on the selection of an item in the PanelBar.
This can be easily done like this:
item.Text = Ajax.ActionLink(...);
item.Encoded = false;
Setting encoded = false is required because the panelbar will html encode the text of the item by default.
Atanas Korchev
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
If I do this, somewhere on my page outside of the PanelBar it works as expected
@Ajax.ActionLink("changeMeLater", "RoundMap", "Round", new {roundId = 14}, new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "result", InsertionMode = InsertionMode.Replace });If I do this inside my PanelBar I get the horrible server error message CS1593: Delegate 'blah blah' does not take 1 arguments
item.Text = Ajax.ActionLink("changeMeLater", "RoundMap", "Round", new {roundId = round.RoundId}, new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "result", InsertionMode = InsertionMode.Replace });item.Encode = false; I forgot that Ajax.ActionLink does not return a string. Try this:
item.Text = Ajax.ActionLink("changeMeLater", "RoundMap", "Round", new {roundId = round.RoundId}, new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "result", InsertionMode = InsertionMode.Replace }).ToHtmlString();
Atanas Korchev
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
Anyone reading this later, I have a typo in one of the posts. It reads
item.Encode = false;It should read
item.Encoded = false;