我想让div id = Delete仅在mode =“Edit”时可见//无法弄明白,谢谢你的帮助。代码如下。似乎超级简单,但我不能让它合作。
@model Credentials.Models.OEMAdd
@{
string mode;
if (Model.provider.Id == null)
{
mode = "Add";
}
else
{
mode = "Edit";
}
ViewBag.Title = mode + " OEM Provider";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<div id="Verify" style="display:none"><input type="submit" class="btn btn-lg btn-primary" value="Verify Login & Save" /></div>
<div id="Delete" style="float:right; margin-right:995px; margin-top:18px"><a href="#" class="btn btn-danger">Delete Profile</a></div>
<br /> <a href="@Url.Action("OEMProviders", new { id = Model.provider.Company.Id } )" class="btn btn-lg">Cancel</a>
<br />
答案 0 :(得分:0)
在这个div周围使用if
@if(mode == "edit"){
<div id="Delete" style="float:right; margin-right:995px; margin-top:18px"><a href="#" class="btn btn-danger">Delete Profile</a></div>
}