我在MVC3視圖頁中有2個表單,基於某些條件我必須隱藏一個表單,但是我收到一些錯誤,找不到錯誤是什麼?下面是代碼,在MVC視圖頁中隱藏表單
@model Models.Common.Details
@{
if (ViewContext.IsChildAction != true && !Request.IsAjaxRequest())
{ Layout = "../../Shared/DefaultLayout.cshtml"; }
else
{ Layout = null; }
}
@using Models.Common;
@{ ViewBag.Title = "Premium";}
<script type="text/javascript" language="javascript">
var urlContent = "@Url.Content("~/")";
var currentYear = "@DateTime.Now.Year";
var currentMonth = "@DateTime.Now.Month";
</script>
<script src="@Url.Content("~/Scripts/UIScripts/paymentmodule/Premium.js?" + DateTime.Now)" type="text/javascript"></script>
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
@Html.AntiForgeryToken()
@Html.HiddenFor(m => m.newPolicyDetails.ReferenceNumber1)
@Html.HiddenFor(m => m.newPolicyDetails.ReferenceNumber2)
@Html.HiddenFor(m => m.newPolicyDetails.ReferenceNumber3)
<input type="submit" id="Settle" name="Settle" value="Settle"/>
}
@{
if (!(Session["User"].Equals(Constant.User)))
{
@using (Html.BeginForm(null,null,FormMethod.post,new{@action="www.somelink.com/abce"}))
{
@Html.ValidationSummary(true)
@Html.AntiForgeryToken()
@Html.HiddenFor(m => m.newPolicyDetails.ReferenceNumber4)
@Html.HiddenFor(m => m.newPolicyDetails.ReferenceNumber5)
@Html.HiddenFor(m => m.newPolicyDetails.ReferenceNumber6)
<input type="submit" id="ok" name="Ok" value="Settle"/>
}
}
}
我已經使用這個代碼@ {} -----基於這個條件,我需要隱藏的第二個形式,因爲它是視圖頁面編寫C#conditon,我不知道是什麼錯誤來了,但我不能去這個觀看頁面本身。 如果我刪除該代碼塊{{-----},一切工作正常。 任何建議傢伙?
Error Message:
UserMessage= Error Occurred at : 07/08/2014 12:03:02.547
Exception Details : System.Web.HttpParseException (0x80004005): Unexpected "using" keyword after "@" character. Once inside code, you do not need to prefix constructs like "using" with "@".
收到什麼樣的錯誤? –
@EhsanSajjad添加了錯誤信息 – Govind
看到答案,希望它有幫助 –