0
我張貼的格式,並檢查它的使用IsPost
完成,但我從來沒有得到我想要的結果:IsPost工作不正常
@if (IsPost)
{
var error = false;
var nom = Request["searchGroup"];
if (nom.IsEmpty())
{
error = true;
@:Fill the form <br />
}
if (!error)
{
Response.Redirect(Href("~/Search/FindGroups"), false);
}
}
<form class="form-inline" method="post" action="~/Search/FindGroups">
<input type="text" class="form-control mb-2 mr-sm-2 mb-sm-0" name="searchGroup" id="searchGroup"/>
<button type="submit" id="searchValidate"> Rechercher </button><br />
</form>
所以這是我的形式,當我發帖的形式與空<input>
它應該顯示'填寫表單',而不是更改頁面,但是每次都會重定向。我沒有看到什麼?
如果你不想重載表單,那麼爲什麼不使用Ajax? – Usman
@Usman嗯,我不太瞭解ajax,那會怎麼做? –
@FlexabustBergson使用'$ .ajax'併爲此返回'JsonResult',並在AJAX調用中使用'success'塊來插入響應數據。 –