I am using a telerik mvc 开发者_开发问答window extension that is triggered from a custom template link in a telerik mvc grid. The window is modal and it contains a form for editing data. After successfully implementing client side validation using a standard html page, I have been trying to implement it in the telerik mvc window. I have not been able to do so successfully. Is this possible? Does anybody have a working example of this?
Thanks Ozzy
You need to load to page in an IFrame. To do this, make sure the url in LoadContentFrom method starts with http or https:
<%= Html.Telerik().Window()
.Name("Window")
.LoadContentFrom("http://www.example.com")
%>
if you're using the Url.Action() helper to get the url, include the protocol parameter to get the full url.
E.g Url.Action("action name","controler name", "http") <--may also need to include route values or null route value dictionary.
To close to window, you'll need to make a call back to the parent view, try this:
add a bool isValid property to your model
if succesfully validated, reload the view with isValid equals true
onload:
var isValid = '<%: Model.IsValid%>';
if(isValid == 'True') { window.parent.$('#MyWindow').data('tWindow').close(); }
It is possible. First make sure you have your ViewModel property that needs validation decorated with the appropriate attribute. Eg: [Required(ErrorMessage = "this is required")]
Then include all the client validation scripts found in telerik's folder in your application.
<script src="../../Scripts/jquery.validate.min.js" type="text/javascript"></script>
Make sure you use the latest build of teleriks extensions. hth.
精彩评论