我有一些IF..ELSE
运算符在我的MVC Partial View
,我的部分视图不是呈现当我使用IF..Else..Operator
在里面,任何人都可以知道我该如何解决这个?
OR
我怎么能做到这一点在其他的方式?MVC部分视图不使用时呈现使用条件运算符(IF..ELSE)
错误: “NetworkError:500内部服务器错误 - http://localhost:50101/TaxRates/EditTaxRates?CountryTaxId=12”
EDIT
我的模型不为空,也CountryId IS NOT NULL
HTML
<a onclick="editTaxRates(@item.CountryTaxId)"><span class="fa fa-2x fa-edit" style="cursor:pointer; color:black" title='Click to Edit Country'></span></a>
<form id="readIODetail" style="z-index:100">
<div id="divAddCountryRecord" class="modal hide fade " tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false" style="width: 700px; left: 46% !important;">
</div>
</form>
jQuery的
function editTaxRates(CountryTaxId) {
var selectedCountryType = $("#selectedCountryType").val();
$.ajax({
type: 'POST',
url: '/TaxRates/EditTaxRates?CountryTaxId=' + CountryTaxId,
success: function (response) {
$("#divAddCountryRecord").empty();
$("#divAddCountryRecord").append(response);
$('#divAddCountryRecord').modal('show');
}
})
}
控制器
public PartialViewResult EditTaxRates(int? CountryTaxId)
{
// conditional code
return PartialView(countryResult);
}
.csHtml(查看)
<div class="modal-body" style="padding-left:10px;overflow-y:auto;">
<div class="row-fluid container">
<div class="span4">
</div>
<div class="row-fluid span12">
<div class="span3">
<p><strong>Country: </strong></p>
</div>
<div class="span5">
@Html.TextBoxFor(m => m.CountryName, new { @readonly = true })
</div>
</div>
<div class="row-fluid span12">
<div class="span3">
<p><strong>Tax-Rate: </strong></p>
</div>
<div class="span5">
@if (Model.CountryId == 1)
{
@Html.TextBoxFor(m => m.TaxRate, new { @id = "C_firstCountry" })
}
else
{
@Html.TextBoxFor(m => m.TaxRate, new { @id = "C_secondCountry" })
}
</div>
</div>
</div>
</div>
您宝贵的意见表示赞赏。
代替'Model => Model ....'使用'model => model.' –
尝试@if(Model.CountryId!= null && Model.CountryId == 1) –
尝试将'@:'放在你的TextBoxFor's。 –