0

我正在使用 Telerik mvc 窗口扩展,它是从 Telerik mvc 网格中的自定义模板链接触发的。该窗口是模态的,它包含一个用于编辑数据的表单。在使用标准 html 页面成功实现客户端验证后,我一直尝试在 Telerik mvc 窗口中实现它。我无法成功地做到这一点。这可能吗?有人有这方面的工作例子吗?

谢谢奥兹

4

2 回答 2

2

您需要在 IFrame 中加载到页面。为此,请确保 LoadContentFrom 方法中的 url 以 http 或 https 开头:

<%= Html.Telerik().Window()        
.Name("Window")        
.LoadContentFrom("http://www.example.com")
%>

如果您使用 Url.Action() 帮助程序来获取 url,请包含协议参数以获取完整的 url。

例如 Url.Action("action name","controler name", "http") <--可能还需要包含路由值或空路由值字典。

要关闭窗口,您需要回调父视图,试试这个:

  1. 为您的模型添加一个 bool isValid 属性

  2. 如果成功验证,则使用 isValid 重新加载视图等于 true

  3. 负载:

    var isValid = '<%: Model.IsValid%>';

    if(isValid == 'True') { window.parent.$('#MyWindow').data('tWindow').close(); }

于 2010-11-30T10:52:16.217 回答
1

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.

于 2011-04-26T15:56:24.413 回答