Ajax.BeginForm Verus using javascript and Json to implement a searchhttp://forums.asp.net/t/1699688.aspx/1?Ajax+BeginForm+Verus+using+javascript+and+Json+to+implement+a+searchSun, 24 Jul 2011 07:28:25 -040016996884506379http://forums.asp.net/p/1699688/4506379.aspx/1?Ajax+BeginForm+Verus+using+javascript+and+Json+to+implement+a+searchAjax.BeginForm Verus using javascript and Json to implement a search <p>i use to implement a &nbsp;search functionalities using ajax.beginform to return a partial view with my desired search and update the current view with the search results without requiring to reload the full pag., but lately i came over how to implement&nbsp; the same functionality using java script directly and return the results as json format; So my question is what are the benefits of using each approach comparing to the other.</p> 2011-07-14T03:37:58-04:004506399http://forums.asp.net/p/1699688/4506399.aspx/1?Re+Ajax+BeginForm+Verus+using+javascript+and+Json+to+implement+a+searchRe: Ajax.BeginForm Verus using javascript and Json to implement a search <p>I like more the javascript . For me it is better as I have more control over it( error, return value, messages...)</p> 2011-07-14T03:52:48-04:004506648http://forums.asp.net/p/1699688/4506648.aspx/1?Re+Ajax+BeginForm+Verus+using+javascript+and+Json+to+implement+a+searchRe: Ajax.BeginForm Verus using javascript and Json to implement a search <p>The main advantage is that you provide a &quot;form context&quot; to all input controls contained in the form. Without a form context no validation logic is automatically applied to the form on the server side. Thus, if you parse new ajax content for validation ...nothing happens. However you can provide manually the form context in your View, or by writing an ad hoc ViewResult</p> <p>Othere minor advantages are that it a little bitless code to write and less chnces to write something wrong. I computes the link automatically based on the action method name etc.</p> <p>However, you have less flexibility. A direct call to the jQuery ajax give you more options. For instance you can receive also JSON instead of Html, do some pre-processing before attaching the new content and so on.</p> <p></p> <p>Personally, I have written a custom View Result to overcome the problem of the form context. This way I am free to choose among the two alternatives. I use Ajax form for simpler thing and direct calls when I need more options</p> 2011-07-14T07:22:48-04:004507588http://forums.asp.net/p/1699688/4507588.aspx/1?Re+Ajax+BeginForm+Verus+using+javascript+and+Json+to+implement+a+searchRe: Ajax.BeginForm Verus using javascript and Json to implement a search <p><span style="font-family:'Verdana','sans-serif'; color:black; font-size:7.5pt">thanks for your reply, actually i do not have that much experience in writing java script from scratch , but it seems that as you mentioned it can give me more flexibility if i need more to implement complex scenarios. but at the end does any approach provide more light weight calls comparing to the other, or both approaches have the same performance effect on the server.</span></p> 2011-07-14T16:32:47-04:004513246http://forums.asp.net/p/1699688/4513246.aspx/1?Re+Ajax+BeginForm+Verus+using+javascript+and+Json+to+implement+a+searchRe: Ajax.BeginForm Verus using javascript and Json to implement a search <p>Hi,</p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>johnjohn123123</h4> but at the end does any approach provide more light weight calls comparing to the other, or both approaches have the same performance effect on the server.</blockquote> <p></p> <p>No matter which approach you use, they are both client side behavior, which is noen of the concern of the performance on the server. But use Jquery.ajax can give you more flexbility to post data, no only form.submit.</p> <p>Hope this helpful,<br> Forest Cheng</p> 2011-07-19T01:43:07-04:004513249http://forums.asp.net/p/1699688/4513249.aspx/1?Re+Ajax+BeginForm+Verus+using+javascript+and+Json+to+implement+a+searchRe: Ajax.BeginForm Verus using javascript and Json to implement a search <p>maybe this can help you:</p> <p><a href="http://amirrajan.net/Blog/asp-mvc-ajax-begin-form-vs-jquery-dhtml-and-microtemplating">http://amirrajan.net/Blog/asp-mvc-ajax-begin-form-vs-jquery-dhtml-and-microtemplating</a></p> 2011-07-19T01:45:53-04:004513420http://forums.asp.net/p/1699688/4513420.aspx/1?Re+Ajax+BeginForm+Verus+using+javascript+and+Json+to+implement+a+searchRe: Ajax.BeginForm Verus using javascript and Json to implement a search <p>if you use Ajax.BeginForm with unobtrusive ajax, then your site degrades nicely when javascript is disabled. the part I dislike with Ajax forms is their use of global namespace for the callback functions. if you are writing a complex app with multiple forms on the page, then this is a really bad feature. its even worse, if the form is on the page more than once (you lose local scoping for each form).</p> <p></p> <p></p> <p>&nbsp;</p> 2011-07-19T04:45:34-04:004521656http://forums.asp.net/p/1699688/4521656.aspx/1?Re+Ajax+BeginForm+Verus+using+javascript+and+Json+to+implement+a+searchRe: Ajax.BeginForm Verus using javascript and Json to implement a search <p></p> <blockquote><span class="icon-blockquote"></span> <h4>francesco abbruzzese</h4> <p></p> <p>The main advantage is that you provide a &quot;form context&quot; to all input controls contained in the form. Without a form context no validation logic is automatically applied to the form on the server side. Thus, if you parse new ajax content for validation ...nothing happens. However you can provide manually the form context in your View, or by writing an ad hoc ViewResult</p> <p>Othere minor advantages are that it a little bitless code to write and less chnces to write something wrong. I computes the link automatically based on the action method name etc.</p> <p></p> </blockquote> <p></p> <p>Sorry i came among this post again !!! , in the above quote you were talking about&nbsp;the&nbsp;advantages of of Ajax.actionlink and NOT the advantages of JQuery!!</p> <p>BR</p> <p>&nbsp;</p> 2011-07-24T03:17:54-04:004521749http://forums.asp.net/p/1699688/4521749.aspx/1?Re+Ajax+BeginForm+Verus+using+javascript+and+Json+to+implement+a+searchRe: Ajax.BeginForm Verus using javascript and Json to implement a search <p>Hi, yes advantagess of ajax acyion links or ajax.beginforms. Then I say that adbvantage of a direct call to jQuery ajax methods has mainly more flexibility, you can do things that cannot be done with action links and ajax forms,</p> <p>Examples of more flexibility are:1) manipulating the data retrieved before attaching them to their traget location2) You can receive json and then use it to create the new content instead of sending html from the server saving Internet BansWidth 3) jQuery ajax methods can be called programatically form javascript, while an action link...just works if someone click it...and so on.</p> <p>As a general rule if what you need to do can be done with action links or ajax forms...do it this way otherwise back up to a direct call. Consider that also Ajax forms and links are built on top of jQuery ajax and at the end call jQuery ajax methods...but they do some service more, but obviously restrict the usage...that's all.</p> 2011-07-24T07:28:25-04:00