I have a view with telerik asp.net mvc button on it. When the user clicks on this button, I would like to redirect to another view. I looked into the control documentation but could not find anything in the Events section. Please help me.
Below is my button code for reference.
<div style="text-align:right">
@(Html.Kendo().Button()
.Name("add")
.Content("Add Project")
.HtmlAttributes(new { type = "button" })
.Events(e => e.Click("GoToCreateView")))
</div>
Thanks.
4 Answers, 1 is accepted
Indeed in the current case you could use the click event of the Button widget and navigate to the view in the event handler.
Let me know if I could assist further on this topic.
Regards,
Dimiter Madjarov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Would you be able to show me an example of the script code inside the click event handler to navigate to a new view?
You could navigate via JavaScript in the event handler.
E.g.
function
onButtonClick(){
window.location.href =
"..."
;
//pass the desired url for the view
}
Regards,
Dimiter Madjarov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

In case anyone else fetches up here...
A server-side solution is available using .Tag() and .HtmlAttributes() to make the button a hyperlink:
@(Html.Kendo()
.Button()
.Name("add")
.Content("Add Project")
.Tag("a")
.HtmlAttributes(new { @href="[desired url]"})
The Html helper Url.Action might alternatively be used for the desired url:
@(Html.Kendo()
.Button()
.Name("add")
.Content("Add")
.Tag("a")
.HtmlAttributes(new { @href=Url.Action("[desired action]", "[desired controller]") }))
In either case, query parameters can also be incorporated (though perhaps unlikely to apply in the OP's scenario).
Hello Hamish,
Thank you for sharing the solution you've found with the community. It might be helpful to someone who is working on a similar to your scenario.