我遇到了这个代码的问题,它显示了;编译期间缺少错误。 我实际上是尝试将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>
});
}
}
})
)
答案 0 :(得分:0)
我想你可能在倒数第二行有一个不必要的)
(关闭.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>
});
}
}
}
)