0

我是 Telerik 和 MVC 的新手,我正在尝试在 Telerik 的页面加载时弹出一个模型表单(允许用户订阅)。这是 Index.cshtml 中的代码,从未调用过测试代码“hello world”。

@model Subscriber
 @{  Html.Telerik().Window()
    .Name("Window")
    .Title("Submit feedback")
    .Content(@<text>
        @using (Html.BeginForm("popupform", "window", FormMethod.Post, new { id = "feedback-form" }))
        {
            <p class="note">Subscribe<strong>not</strong> be saved.</p>

            @Html.LabelFor(model => model.Email)
            @Html.TextBoxFor(model => model.Email)
            @Html.ValidationMessageFor(model => model.Email)

            <div class="form-actions">
                <button type="submit" class="t-button t-state-default">Submit feedback!</button>
            </div>
        }
        </text>)
    .Width(400)
    .Draggable(true)
    .Modal(true)
    .Visible(false)
    .Render();
 } 

 @{
    ViewBag.Title = "Home Page";
 }
@{
Html.Telerik().ScriptRegistrar().OnDocumentReady(
@<text>
    // put some javascript goodness in here
   alert('hello world');
   $('#Window').data('tWindow').center().open();
</text>);
}
4

1 回答 1

0

试试这个:

....
@{
    Html.Telerik().ScriptRegistrar().OnDocumentReady(@"OnInit();");
}
<script type="text/javascript">
function OnInit() {
     // put some javascript goodness in here
     alert('hello world');
     $('#Window').data('tWindow').center().open();  
}

我想你的问题出在标签上,但不确定。之前的代码在任何情况下都必须工作。

于 2012-10-17T09:53:42.130 回答