我有一个查询字符串,我想进入我的剃刀视图。 example.com/25?Type=1&Assigned=1
显示某些HTML基于关闭查询字符串
我想根据查询字符串是否包含某些值来更改我的html。我试过
@if (Request.QueryString["Type=1&Assigned=1"])
{
<button id="type1" class="btn-t btn-success type-button"
onclick="SetType(1);"><i class="fa fa-info-circle fa-fw"></i>Invitation</button>
}
else {
<button id="type1" class="btn-t btn-xxxx
type-button" onclick="SetType(1);"><i class="fa fa-info-circle fa-fw">
</i>Invitation</button>
}
但它只显示else。我究竟做错了什么?
我对razor视图不太熟悉,但是我认为它更像'Request.QueryString [“Type”] ==“1”和Request.QueryString [“Assigned”] == “1”'。您不能检查整个查询字符串,而是检查每个单独参数的值。编辑:它看起来像有人打我回答一拳。 – user2366842