【发布时间】:2015-07-13 13:59:24
【问题描述】:
我有一个查询字符串,我想将它传递到我的剃刀视图中。 example.com/25?Type=1&Assigned=1
我想根据查询字符串是否包含某些值来更改我的 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。我做错了什么?
【问题讨论】:
-
我对剃刀视图不太熟悉,但我猜它更像
Request.QueryString["Type"] == "1" and Request.QueryString["Assigned"]=="1"。您不能检查整个查询字符串,而是检查每个单独参数的值。编辑:看起来有人在答案上击败了我。
标签: c# asp.net asp.net-mvc query-string