asp.net mvc - how to render a full view using Ajax.BeginForm -
I have a partial view in which an Ajax. There is a form in which an UpdateTargetID is set when the validation on the form fails, the update target ID is replaced with verification errors, but when there are no verification errors, users should be redirected to the new page.
Code in my partial view
& lt; Div id = "div_UID" & gt; & Lt;% (Ajax.BeginForm ("FindChildByUID", new AjaxOptions {UpdateTargetId = "div_UID"}})) {%> & Lt; P & gt; & Lt; Label & gt; UID: & lt; / Labels & gt; & Lt;% = Html.TextBox ("UID")% & gt; & Lt; / P & gt; & Lt; Input type = "submit" value = "continue" /> & Lt;%}% & gt; & Lt; / Div & gt; & Lt; / Pre & gt;
The code in my controller is as follows: [AcceptVerbs] (HTVBrbs.post) Public Action Result FindChildByUID {student student} {student matching Student = _Student Service FindChildByUID (student.UID); If (matching student == blank) {ModelState.AddModelError ("UID", string.format ("No matching child found for UID entered: {0}", student.UID)); Return partial view (); } Else {// Full View Return Redirect Action ("ConfirmChildDetails", matching student); }}
Therefore, because I failed to display it completely full view, because it always seems to be replicating full view in the UpdateTargetID division specfied in Ajax.BeginForm. / P>
thanks
What your AJAX post is doing, making a request and Waiting for an input on the page in HTML for a response. The configuration is such that whatever HRL is refunded, will be injected into the div that you named "div_UID".
I usually avoid such scenarios and use traditional posting if a redirect is necessary on a successful outcome post.
I think you can do this by using jQuery like Ajax.BeginForm (or just set a callback function for your Ajax.BeginForm) instead of:
(Target) "$ {form}" function {submit form (form) {$ (form). $ (Form) .jax submit ({target: "#div_to_update", breakthrough: checklist}};} function checkVivility (response text) {var value = $ (" If you have only partial "did_process_succeed" The There is a hidden field in the form and set the value of right or wrong based on some logic in your controller.There are other ways in which there may be chimes inside someone else. I hope that This helps for now.
Comments
Post a Comment