简体   繁体   English

Kendo Tabstrip中的Razor语法

[英]Razor Syntax in Kendo Tabstrip

I am having issue with this code and it shows ; 我对此代码有疑问,它显示了; missing error during compilation. 编译期间缺少错误。 I am actually trying to switch a aspx code to razor syntax mvc5 project. 我实际上正在尝试将aspx代码切换为razor语法mvc5项目。 The code works in aspx, so I am not sure what i am doing wrong in razor. 该代码在aspx中有效,所以我不确定我在剃刀中做错了什么。 Any help would be appreciated. 任何帮助,将不胜感激。

tabstrip.Add()
                                                      .Text(item.Title)
                                                      //.HtmlAttributes(new { tabindex = "-1" })
                                                      .Selected(true)
                                                      .Content(() =>
                                                      {

                                                          using (Html.BeginForm(null, null, FormMethod.Post, new { id = "tabForm" }))
                                                          {
                                                                @<div style="width:980px;min-height:562px;margin-left:0px;margin-right:0px">
                                                                <div>
                                                                    @Html.ValidationSummary(false);
                                                                    @RenderBody();
                                                                </div>

                                                                <div style="padding-top:30px; text-align:center;">
                                                                    @{
                                                                        string roStyle = ViewData[Constants.ReadOnly].ToString();
                                                                        string roMessage = "";
                                                                        string roButtonText = "Cancel";

                                                                        //if (helper_readonly.Value == "true")
                                                                        if (Model.helper_readonly == "true")
                                                                        {
                                                                            roStyle = "style='display:none;'";
                                                                            roMessage = "READ ONLY - changes are not saved";
                                                                            roButtonText = "Close";
                                                                        }
                                                                    }
                                                                    <table border="0" width="100%">
                                                                        <tr>
                                                                            <td style="width:30%;" align="left">
                                                                                <input type="button" id="ToggleDiagnosticsButton" value="Show Diagnostics" class="k-button cancel" style="display:none;" />
                                                                            </td>
                                                                            <td style="width:40%;" align="center">
                                                                                <input type="submit" id="SaveButton" value="Save" class="k-button" @disabled @roStyle />&nbsp;&nbsp;
                                                                                <input type="submit" id="CancelButton" value="@roButtonText" class="k-button cancel" onblur="LastOnBlur()" />
                                                                                <input type="submit" id="submithelper" value="Cancel" class="cancel" style="display:none;" />
                                                                            </td>
                                                                            <td style="width:30%;" align="right">
                                                                                &nbsp;&nbsp;<span style="color:Red;">@roMessage</span>
                                                                            </td>
                                                                        </tr>
                                                                    </table>

                                                                </div>

                                                                @Html.Hidden("NextActionHelper", Model.NextActionHelper);
                                                                @Html.Hidden("UserFormAction", Model.UserFormAction);
                                                                </div>
                                                          }
                                                      });

The compilation error with ; 出现编译错误; missing is on the second last line. 倒数第二行。

Complete code: 完整的代码:

@(Html.Kendo()
              .TabStrip()
              .Animation(false)
              .Name("tabstripForms")
              .Events(events => { events.Select("onFormTabSelect"); })
              .Items(tabstrip =>
              {
                  foreach (var item in ViewData[Constants.ViewDataKey_ActionTabMenu] as
                                       List<BusinessEntities.DTO.Shared.MvcMenuItem>)
                  {
                      bool selected = item.Action.ToLower() == ViewData[Constants.ViewDataKey_CurrentAction].ToString().ToLower() ? true : false;
                      if (selected)
                      {
                          //helper_post_on_cancel.Value = item.PostBackOnCancel.ToString();
                          Model.helper_post_on_cancel = item.PostBackOnCancel.ToString();
                          //helper_post_on_tabselect.Value = item.PostBackOnTabSelect.ToString();
                          Model.helper_post_on_tabselect = item.PostBackOnTabSelect.ToString();

                          tabstrip.Add()
                                                  .Text(item.Title)
                                                  //.HtmlAttributes(new { tabindex = "-1" })
                                                  .Selected(true)
                                                  .Content(() =>
                                                  {

                                                      using (Html.BeginForm(null, null, FormMethod.Post, new { id = "tabForm" }))
                                                      {
                                                            @<div style="width:980px;min-height:562px;margin-left:0px;margin-right:0px">
                                                            <div>
                                                                @Html.ValidationSummary(false);
                                                                @RenderBody();
                                                            </div>

                                                            <div style="padding-top:30px; text-align:center;">
                                                                @{
                                                                    string roStyle = ViewData[Constants.ReadOnly].ToString();
                                                                    string roMessage = "";
                                                                    string roButtonText = "Cancel";

                                                                    //if (helper_readonly.Value == "true")
                                                                    if (Model.helper_readonly == "true")
                                                                    {
                                                                        roStyle = "style='display:none;'";
                                                                        roMessage = "READ ONLY - changes are not saved";
                                                                        roButtonText = "Close";
                                                                    }
                                                                }
                                                                <table border="0" width="100%">
                                                                    <tr>
                                                                        <td style="width:30%;" align="left">
                                                                            <input type="button" id="ToggleDiagnosticsButton" value="Show Diagnostics" class="k-button cancel" style="display:none;" />
                                                                        </td>
                                                                        <td style="width:40%;" align="center">
                                                                            <input type="submit" id="SaveButton" value="Save" class="k-button" @disabled @roStyle />&nbsp;&nbsp;
                                                                            <input type="submit" id="CancelButton" value="@roButtonText" class="k-button cancel" onblur="LastOnBlur()" />
                                                                            <input type="submit" id="submithelper" value="Cancel" class="cancel" style="display:none;" />
                                                                        </td>
                                                                        <td style="width:30%;" align="right">
                                                                            &nbsp;&nbsp;<span style="color:Red;">@roMessage</span>
                                                                        </td>
                                                                    </tr>
                                                                </table>

                                                            </div>

                                                            @Html.Hidden("NextActionHelper", Model.NextActionHelper);
                                                            @Html.Hidden("UserFormAction", Model.UserFormAction);
                                                            </div>
                                                      }
                                                  });

                                                                    }
                                                                    else
                                                                    {
                                                                        tabstrip.Add()
                                                                             .Text(item.Title)
                                                                             //.HtmlAttributes(new { tabindex = "-1" })
                                                                             .Selected(false)
                                                                             .Content(() =>
                                                                             {
                                                                                 @<div style="min-height: 562px;">
                                                                                    <div class="k-loading-mask" style="width:982px;height:562px;">
                                                                                        <div class="k-loading-image">
                                                                                        </div>
                                                                                    </div>
                                                                                </div>



                                                                             });
                                                                    }
                  }
              })
        )

I think you might have had an unnecessary ) on the second last line (closing off .Items() ). 我想你可能有不必要的)在倒数第二个行(封闭.Items() Took the liberty of formatting aswell ;) 也采取了格式化的自由;)

@(Html.Kendo()
    .TabStrip()
    .Animation(false)
    .Name("tabstripForms")
    .Events(events => { events.Select("onFormTabSelect"); })
    .Items(tabstrip =>
    {
        foreach (var item in ViewData[Constants.ViewDataKey_ActionTabMenu] as List<BusinessEntities.DTO.Shared.MvcMenuItem>)
        {
            bool selected = item.Action.ToLower() == ViewData[Constants.ViewDataKey_CurrentAction].ToString().ToLower() ? true : false;
            if (selected)
            {
                //helper_post_on_cancel.Value = item.PostBackOnCancel.ToString();
                Model.helper_post_on_cancel = item.PostBackOnCancel.ToString();
                //helper_post_on_tabselect.Value = item.PostBackOnTabSelect.ToString();
                Model.helper_post_on_tabselect = item.PostBackOnTabSelect.ToString();

                tabstrip.Add()
                .Text(item.Title)
                //.HtmlAttributes(new { tabindex = "-1" })
                .Selected(true)
                .Content(() =>
                {
                    using (Html.BeginForm(null, null, FormMethod.Post, new { id = "tabForm" }))
                    {
                        @<div style="width:980px;min-height:562px;margin-left:0px;margin-right:0px">
                             <div>
                                 @Html.ValidationSummary(false);
                                 @RenderBody();
                             </div>

                             <div style="padding-top:30px; text-align:center;">
                                 @{
                                     string roStyle = ViewData[Constants.ReadOnly].ToString();
                                     string roMessage = "";
                                     string roButtonText = "Cancel";

                                     //if (helper_readonly.Value == "true")
                                     if (Model.helper_readonly == "true")
                                     {
                                         roStyle = "style='display:none;'";
                                         roMessage = "READ ONLY - changes are not saved";
                                         roButtonText = "Close";
                                     }
                                 }
                                 <table border="0" width="100%">
                                     <tr>
                                         <td style="width:30%;" align="left">
                                             <input type="button" id="ToggleDiagnosticsButton" value="Show Diagnostics" class="k-button cancel" style="display:none;" />
                                         </td>
                                         <td style="width:40%;" align="center">
                                             <input type="submit" id="SaveButton" value="Save" class="k-button" @disabled @roStyle />&nbsp;&nbsp;
                                             <input type="submit" id="CancelButton" value="@roButtonText" class="k-button cancel" onblur="LastOnBlur()" />
                                             <input type="submit" id="submithelper" value="Cancel" class="cancel" style="display:none;" />
                                         </td>
                                         <td style="width:30%;" align="right">
                                             &nbsp;&nbsp;<span style="color:Red;">@roMessage</span>
                                         </td>
                                    </tr>
                                </table>

                            </div>

                            @Html.Hidden("NextActionHelper", Model.NextActionHelper);
                            @Html.Hidden("UserFormAction", Model.UserFormAction);
                       </div>
                   }
               });
           }
           else
           {
               tabstrip.Add()
                   .Text(item.Title)
                   //.HtmlAttributes(new { tabindex = "-1" })
                   .Selected(false)
                   .Content(() =>
                   {
                       @<div style="min-height: 562px;">
                           <div class="k-loading-mask" style="width:982px;height:562px;">
                               <div class="k-loading-image">
                               </div>
                           </div>
                       </div>
                   });
           }
       }
   }          
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM