[英]Razor Syntax in Kendo Tabstrip
我對此代碼有疑問,它顯示了; 編譯期間缺少錯誤。 我實際上正在嘗試將aspx代碼切換為razor語法mvc5項目。 該代碼在aspx中有效,所以我不確定我在剃刀中做錯了什么。 任何幫助,將不勝感激。
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 />
<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">
<span style="color:Red;">@roMessage</span>
</td>
</tr>
</table>
</div>
@Html.Hidden("NextActionHelper", Model.NextActionHelper);
@Html.Hidden("UserFormAction", Model.UserFormAction);
</div>
}
});
出現編譯錯誤; 倒數第二行。
完整的代碼:
@(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 />
<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">
<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>
});
}
}
})
)
我想你可能有不必要的)
在倒數第二個行(封閉.Items()
也采取了格式化的自由;)
@(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 />
<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">
<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.