我试图根据 IF 条件在我的页面中显示特定的 HTML,我有一个静态变量来确定页面的状态和显示的内容,问题是在第一个页面加载后,不再呈现 html。
这是我的一个 if :
@if (WhiteLabel.Controllers.GlobalVariables.Step == 2)
{
<text>
<div id="thirdDiv" data-step="3" class="no-show">
<div class="span6">
我有一个按钮来更改全局变量的值,例如:
<form action="UploadPhoto/setNext" method="post">
<button class="btn" type="submit">siguiente</button>
</form>
它进入了这个控制器的方法:
public ActionResult setNext()
{
if (GlobalVariables.Step < 3)
{
GlobalVariables.Step += 1;
}
else
{
RedirectToAction("AdjustDots", "VirtualTesterController");
}
return View("Load");
}
更新完整代码:
@if (WhiteLabel.Controllers.GlobalVariables.Step == 1)
{
<div id="firstDiv" data-step="1" >
<!-- SUBIR FOTO -->
<div class="row-fluid">
<div class="span3">
<div class="md-your-data">
<div class="hd">
<h2>1. @ViewBag.Strings["completarDatos"]</h2>
</div>
<div class="bd">
<ul>
<li>
<div class='selectBox'>
<span class='selected' id="ageSelected">@ViewBag.Strings["rangoEdad"]</span>
<span class='selectArrow'></span>
<div class="selectOptions">
<span class="selectOption" value="Option 1">Option 1</span>
<span class="selectOption" value="Option 2">Option 2</span>
<span class="selectOption" value="Option 3">Option 3</span>
</div>
</div>
</li>
<li>
<div class='selectBox'>
<span class='selected' id="skinToneSelected">@ViewBag.Strings["tonoPiel"]</span>
<span class='selectArrow'></span>
<div class="selectOptions">
<span class="selectOption" value="Option 1">Option 1</span>
<span class="selectOption" value="Option 2">Option 2</span>
<span class="selectOption" value="Option 3">Option 3</span>
</div>
</div>
</li>
<li>
<div class='selectBox'>
<span class='selected' id="skinTypeSelected">@ViewBag.Strings["tipoPiel"]</span>
<span class='selectArrow'></span>
<div class="selectOptions">
<span class="selectOption" value="Option 1">Option 1</span>
<span class="selectOption" value="Option 2">Option 2</span>
<span class="selectOption" value="Option 3">Option 3</span>
</div>
</div>
</li>
</ul>
</div>
<div class="ft">
</div>
</div>
</div>
<div class="span3">
<div class="md-upload-photo">
<div class="hd">
<h2>2. @ViewBag.Strings["SubiTuFoto"]</h2>
</div>
<div id="pictureDiv" class="bd">
<div id="dropPicture" class="photo-cont no-photo" ondragover="allowDrop(event)" ondrop="onDrop(event)">
<div id="picDiv"></div>
</div>
</div>
<div class="ft">
<div class="file-input-wrapper">
<button class="btn-file-input">@ViewBag.Strings["subir"]</button>
<input id='file' class="btn-file" type='file' accept="image/*" onchange="manageFilePicker(event)" />
</div>
@using (Html.BeginForm("setNext", "UploadPicture"))
{
<button class="btn" type="submit">Siguiente</button>
}
</div>
</div>
</div>
<div class="span6">
<div class="md-model-photo">
<div class="hd">
<h2>@ViewBag.Strings["Elegirfotodemodelo"] </h2>
</div>
<div class="bd">
<ul id="modelsList">
<li>
<img src="~/Content/images/imagen-modelo-upload.png" alt="" />
</li>
<li>
<img src="~/Content/images/imagen-modelo-upload.png" />
<img src="~/Content/images/imagen-modelo-upload.png" alt="" />
</li>
<li>
<img src="~/Content/images/imagen-modelo-upload.png" alt="" />
</li>
<li>
<img src="~/Content/images/imagen-modelo-upload.png" alt="" />
</li>
</ul>
</div>
<div class="ft">
</div>
</div>
</div>
</div>
<!-- END SUBIR FOTO -->
</div>
}
@if (WhiteLabel.Controllers.GlobalVariables.Step > 2)
{
<div class="row-fluid">
<!-- BEGIN MANAGE PHOTO -->
<div id="secondDiv" data-step="2" class="no-show">
<div class="span6">
<div class="md-adjust-photo-img">
<div class="bd">
<div class="img-cont">
<img src="~/Content/images/img-modelo.png" alt="" />
</div>
</div>
</div>
</div>
@if (WhiteLabel.Controllers.GlobalVariables.Step == 2)
{
<div id="thirdDiv" data-step="3" class="no-show">
<div class="span6">
<div class="md-adjust-photo-data step-1">
<div class="hd">
<h3>4. @ViewBag.Strings["encuadrarFoto"]</h3>
<p>@ViewBag.Strings["encuadrarFotoDesc"]</p>
</div>
<div class="bd">
</div>
<div class="ft">
@using (Html.BeginForm("setPrevious", "UploadPicture"))
{
<button class="btn" type="submit">Atras</button>
}
@using (Html.BeginForm("setNext", "UploadPicture"))
{
<button class="btn" type="submit">Siguiente</button>
}
</div>
</div>
</div>
</div>
}
@if (WhiteLabel.Controllers.GlobalVariables.Step == 3)
{
<div id="fourthDiv" data-step="4" class="no-show">
<div class="span6">
<div class="md-adjust-photo-data step-2">
<div class="hd">
<h3>5. @ViewBag.Strings["brilloYcontraste"]</h3>
<p>@ViewBag.Strings["brilloYcontrasteDesc"]</p>
</div>
<div class="bd">
<div class="col">
<span>@ViewBag.Strings["brightness"]</span>
<div class="tone-bar">
<span></span>
</div>
</div>
<div class="col">
<span>@ViewBag.Strings["contrast"]</span>
<div class="tone-bar">
<span></span>
</div>
</div>
</div>
<div class="ft">
@using (Html.BeginForm("setPrevious", "UploadPicture"))
{
<button class="btn" type="submit">Atras</button>
}
@using (Html.BeginForm("setNext", "UploadPicture"))
{
<button class="btn" type="submit">Siguiente</button>
}
</div>
</div>
</div>
</div>
}
</div>
</div>
}