몇 가지 비슷한 질문을 보았지만 작동시키지 못했습니다.Ajax.BeginForm이 작동하지 않는 이유는 무엇입니까?
양식에 일부 라디오 버튼이 있습니다. 옵션을 선택하고 제출 버튼을 클릭하는 대신 사용자가 라디오 버튼을 클릭 할 때 양식을 제출하고 싶습니다.
그래서 제출 단추를 숨기고 버튼 클릭을 에뮬레이션하는 자바 스크립트 기능을 배치했습니다. 버튼 클릭으로 작동 시키려고했으나 문제가되지 않습니다. 내보기에
내가 가진 :
<script type="text/javascript" src="/Scripts/jquery-1.9.1/jquery-1.9.1.min.js" ></script>
<script type="text/javascript" src="/Scripts/jquery-1.9.1/jquery.unobtrusive-ajax.min.js"></script>
<script type="text/javascript">
function change() {
$('#buttonradio').click();
}
</script>
<h2>Dashboard</h2>
<div class="Dashboard" id="itemsDshBrd" style="overflow:auto;height:97%;">
<div id="DshBrdRadioGroup" style="float:right;font-size:small">
<% using (Ajax.BeginForm("Index", "DshBrd", new { value = 1 }, new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "stations" })) { %>
<input class="radioclass" id="r1" name="radiogroup" type="radio" value="1" onclick="change()" checked/> A
<input class="radioclass" id="r2" name="radiogroup" type="radio" value="2" onclick="change()"/> B
<input class="radioclass" id="r3" name="radiogroup" type="radio" value="3" onclick="change()"/> C
<input class="radioclass" id="r4" name="radiogroup" type="radio" value="4" onclick="change()"/> D
<input id="buttonradio" type="submit" value="Submit" style="visibility:hidden"/>
<% } %>
</div>
<div id="stations">
<% Html.RenderPartial("~/Views/DshBrd/Stations.ascx"); %>
</div>
</div>
내가 값을 보내고있다 것을 알고 * = 내 컨트롤러 1.
내가 가진 :
[HttpPost]
public ActionResult Index(int value)
{
if (Request.IsAjaxRequest())
{
return PartialView("~/Views/DshBrd/Stations.aspx");
}
return View("~/Views/DshBrd/Index.aspx");
}
을 Request.IsAjaxRequest()
가 절대없는 곳 참된.
내있는 Web.Config도 OK입니다 :
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
어떤 아이디어?
요청이 실제로 무엇인지 확인 했습니까? 아니면 심지어 여기 도착한다면? – Tdelang
HttpRequestBase입니다. 나는 또한 HttpContext.Request.IsAjaxRequest()를 시도했지만 작동하지 않았다. – Lucas