JQuery-Mobile and ASP.Net - AJAX or Postback? - asp.net

I've been developing ASP.Net for the past and until recently come across a mobile project. Jquery-Mobile seems perfect as a framework for this, so I just dived into it.
Currently I'm using ASP.Net approach to put server controls on a page, then use jqm to enhance those controls to make them looks mobile. I actually do postback to collect form data and process them in code-behind.
To avoid a full page refresh, I had to mix them with updatepanel too. Somehow I got them working but deep down I just feel this isn't the right way (or efficient way) of doing it.
There's too much complication of mixing things up to get them right, so I think maybe I should just avoid postback and do everything-else in pure AJAX requests?
$.ajax({
type: 'POST',
url: "/GetName",
data: "{}",
contentType: "application/json; charset=utf-8"
})
.success(function (response) {
alert(response);
});
Code-behind:
[WebMethod ()]
public String GetName()
{ return "Jack"; }
Questions:
This works, but is this the better way to go with jQuery-Mobile websites, or this is just another bad example?
Is UpdatePanel and postback a bad idea for this scenario? (I know they work)
If AJAX is preferred, how do I go about populating a dropdownlist on pageload (Not server control)? Sending an AJAX request to populate dropdownlist on $(document).ready() seems stupid to me
What I'm looking for is rules of thumb of developing a mobile site, I don't want to steer too far away from what should be doing right. Your inputs are very much appreciated. Thanks.

asp.net Web Forms and jQuery Mobile really don't work together. The postback model breaks the way that jQuery Mobile ajax works and it will fall appart when you have more than a single page or form. Specifically Web Forms requires a single <form> tag that wraps all server side controls and you cannot introduce additional "internal" forms. jQuery Mobile really works best with the ajax model and one or more "pages" (<div data-role="page">) and forms that are contained within the DOM. Update panels will ultimately cause chaos.
One approach is to simply turn off jQuery Mobile ajax loading. You can do that with this:
//note that the order of script loading here is critical.
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script>
$(document).bind(“mobileinit”, function() {
$.mobile.ajaxEnabled = false;
});
</script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js">
</script>
but in the end, you won't have a highly efficient web site. If you site is running over a local wireless network, it may be good enough.
I work in a mostly Web Forms environment and had a need for a Web Forms based jQuery Mobile app and coded 5 or so "pages" as a single static html file. I then relied on JavaScript and jQuery ajax loading to ASMX web service end points. I also made extensive use of KnockoutJS but I certainly could have relied solely of JavaScript and jQuery ajax to pull data (and in my case, the app was of a reporting nature with no data updating.) If you are saving data, you can use the same technique.
An even better approach is to go with asp.net MVC which eliminates the forced postback model and allows fine grained control over where your <form> tags are placed.
I am working on a larger mobile site and using MVC for the back end and taking full advantage of Razor views but in the end, I am relying on client side ajax calls for all data and KnockoutJS for almost all dynamic markup. In the end, my client side app isn't all that different between Web Forms and MVC. MVC based controllers are easier to work with for ajax end points and the solution is cleaner.
In general, I would lump both solutions into the "single page application" aka SPA approach. There are other approaches that might work with Web Forms but in my limited exploration, this was the best option.

Related

How to integrate Jquery Mobile with an existing ASP.net WebForms application

I have an existing ASP.net 4.5 webforms application that I want to make into a "WebApp"-like application for mobile browsers.
What I'm mainly interested in is the graphics / sizing / scaling aspect, since the WebForms site works well with mobile browsers already, but it looks ugly and not "mobile" at all.
Reading around, I came across jQuery mobile, which at a glance seems perfect: just including it in my website turns every element of the page "mobile friendly" (fixed page size, big buttons and elements, auto stretching, etc.).
But my initial enthusiasm was short lived: as soon as I tried to use the website, I noticed that while the graphics were perfect, including JQ mobile broke almost all the logic, for example:
DropDownLists stopped generating postbacks
Clicking on LinkButtons stopped working (nothing happens on click)
UpdatePanels broke completely (the ajax calls don't fire anymore)
MultiViews broke completely (they get reset to the initlia View on
every postback)
Am I doing something wrong, or is it just that WebForms and JQuery Mobile are just incompatible?
If they are incompatible, can anyone suggest an alternative to make my website look like a mobile web app (other than re-designing everything by hand that is).
I use asp.net webforms in conjunction with jQuery Mobile and they can work well together. However it takes some forethought and planning, and probably some new ways of doing things compared to the traditional webforms approach. So converting an existing webapp is not as quick and simple as you would like.
Some hints:
If you are using a single aspx page with multiple data-role="page" elements, consider putting all of them within one FORM element so that asp.net postbacks/updatePanels can work.
For linkbuttons, you will most likely need to turn off the default AJAX loading of page links in jQM.
In many cases, instead of using postbacks on controls, use client-side scripts to make async calls via PageMethods in the codebehind, or WebMethods in a WebService(asmx). If you are more comfortable with UpdatePanels, these should still work if you have everything inside a form tag and a scriptmanager within the form tag too.
DropDowns do get restyled by jQM, so you might want to catch the change event in javascript and then either use async calls or fire the postback via javascript.
Here are some other opinions:
JQuery-Mobile and ASP.Net - AJAX or Postback?
How to mix jQuery Mobile and ASP.NET
jQueryMobile in ASP.NET WebForm
If you choose to have Ajax enabled with jquery mobile JQM [which is preferred when using JQM to give the user feeling a native app], you won't have the post back anymore. That is not good because you would lose a lot of built in features like validation controls, built in request validations....
So, one of the options would be using WCF restful service and have it compatible with asp.net (by having this in the web config: serviceHostingEnvironment aspNetCompatibilityEnabled="true"). In this case, you need to mitigate security threats like script injection and cross side request forgery and .... inside with the WCF service as there is no built in request validation.
And now some JQM gotchas:
In order to avoid a lot of surprise, you may have only one page in the DOM by removing previous page from the DOM. This way, you don't need to worry about having multiple items with the same id in the DOM.
The other thing is binding events. if you have a java script in you master page and you have let say a click event to bind, make sure to use one instead of on. otherwise, it behaves unexpectedly.
For the client side validation jquery validation works fine and easy to use and no conflict with JQM.

Load ASP.Net User Controls via jQuery AJAX

I have mini modules(think iGoogle) that are currently loaded via the page calling LoadUserControl method and loading that control into PlaceHolders. I need to switch that implementation to loading the controls through a jQuery AJAX request. The problem currently lies in the fact that when I perform an AJAX Get, I can load the modules by appending them to the content but none of the functionality that would otherwise be working on a normal loaded control is there. For example, when I select a different option on the a DDL the page refreshes and nothing changes. I suspect because it is because the methods aren't being tied in when I perform a load through AJAX. Additionally when I use this method my flash content is not being loaded.
Am I doing something wrong here, or is there a better solution ?
$.ajax({
url: '/modules/UserModules.aspx?CID=12345',
type: "GET",
dataType: "html",
success: function(data) {
$('#column1').append($(data).find('div#lm li'));
$('#column2').append($(data).find('div#cm li'));
$('#column3').append($(data).find('div#rm li'));
alert('Load was performed.');
}
});
When you post back to the server, the server doesn't know about your user control because it was added to the page dynamically. Actually, you render the UC HTML, then add part of the rendered HTML to your page.
I would recommend steering clear of posting back to the server and using jQuery to retrieve any data using a Page Method or web method when you make a selection using your DDL.
I'm not sure I see the utility in using a UC for this. There are a number of ways to do this sort of thing. Like Jamie said, you can have a plain .aspx page that uses web methods. An asmx page. You can also not use web methods and just do as you would with php or classic ASP by writing your string results directly and processing them (shouldn't be your first choice though!).
But the most important thing you can take from this is debugging. Put a break point in your UC code to track server side. Use Firebug: open it, choose console and watch to see if your GET requests are actually doing what they need to. These days, you rarely need an alert to debug.

Is it Asp.Net or Ajax or can both technologies be used together when developing web sites?

1) A while ago I’ve started learning Asp.Net, but then I’ve heard that Ajax is “the new thing”. Since I don’t want to throw away the time I’ve invested into Asp.Net, I’d like to know if it is a common/recommended practice to use both technologies ( Asp.Net and Ajax) when creating websites and web apps in general?
2) If it indeed is a common practice to use the two technologies together, is that only true for server-side Ajax and Asp.Net or can client-side Ajax also be used in conjunction with Asp.Net?
thanx
EDIT:
A)
The only problem is that it can be a
bit trickery to do ajax request using
jquery when using asp.net
webforms(asp.net mvc was designed with
frameworks like jquery in mind so it
is easier to do).
Are you implying that perhaps jquery could be too much of a hassle when used together with webforms and thus I should think of using Asp.Net Ajax instead?
B) Little I read on ajax is that it also needs to call web services or some other technology that provides similar functionality to web services. If true, which technology do you use ( WCF or Asp.Net web services or … )?
C) Is Ajax a subsection of jquery? Thus, to understand Ajax, will I need to purchase only a book on jquery or will I also need to read a book with Ajax in its title?
You can use both, and it is common to use both. MS has a toolkit around using AJAX on asp.net sites:
http://www.asp.net/ajax/
1) Yes it is common to use Ajax and Asp.net on the same website. I do it all the time(in fact if you turn off javascript on my sites they won't work too well as so much is AJAX). AJAX allows for requests to the server to be made without refreshing the page you still need a serverside language to do stuff with that request. You also need the load the page for the first time so asp.net controls still are needed and in fact if your using asp.net ajax then you can use update panels where you put controls into that automatically become ajax enabled.
2) I am not sure what you mean but Ajax is mostly javascript so it lives on the client side and sends requests to the server side.
Edit
Ok I skimmed most of the stuff in those chapters. AJAX server side is where most of the rendering is done on the server side. So the update panel is an ajax server side control. You drag it on to your webform throw some other server side controls into it and a button. If a user then clicks on that button in the update panel an ajax request is made to the server and you can grab all the stuff you need and use C# to change it. You never have to write one line of javascript code to make that happen.
Of course that has a price though for instance an update panel does not do a true ajax request because of the page life cycle. If you actually watch the code through the debugger you will notice it will go through the page life cycle but in the end will just rerender that update panel so there is a bit more over head then if you did it yourself.
Client side Ajax is basically Microsoft trying to make it easier for you to do javascript by trying to make it more like C# syntax and giving you built in methods. A problem is that alot of people throw the buzz word Ajax too often around and call stuff that should not be called Ajax when it should be just called javascript.
This seems to be the case with this client side ajax as most of what I seen in the client side ajax chapter is almost all javascript. Like in "Figure 33.8. Selecting a menu item." all it seems to be is your click on a choose then it displays the name of that button that is not really Ajax.
Ajax to me is when you actually make a server request to post or get some information with out the page refreshing(ie full post back). For example if you got a form of data that you want to send to the server to be saved in a database. If you would hit the save button and that form data would be sent to the server without the page refreshing then that would be an Ajax request.
Most of the stuff in the ajax tool kit is more javascript
http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/Calendar/Calendar.aspx
For instance the calendar control to make it select different dates it is not doing any sort of request to the server since it is all javascript so why would it be ajax if it never posts to the server?
If you would take the value in the textbox that the calendar control puts the date in and post it to the server without refreshing the page that would be an Ajax request.
Finally I would not be too worried about asp.net webforms going anywhere anytime soon. I believe the guy who wrote that article about asp.net going to dye is the guy who made Ajax or was involved some how with the development of Ajax so he is probably biased.
Besides look its been 5 years now since he posted that and asp.net is stronger then ever. Ajax still needs a server to connect to, you still need to render the initial page load with either straight html or asp.net server controls.
Edit 2
1) Yes I think jquery is better the MS ajax for a couple reasons:
It uses less resources then drag and
drop controls
It simplifies javascript alot as it
makes it easier to use(such as
selecting html controls,etc). So if
I was using MS ajax I probably still
be using jquery for the selectors it
has so it is kinda redundant to use
both unless you have a good reason
too.
The only problem is that it can be a bit trickery to do ajax request using jquery when using asp.net webforms(asp.net mvc was designed with frameworks like jquery in mind so it is easier to do).
2) You really only need to learn jquery and not even javascript. I read a javascript book in like a day then jumped into jquery without even doing on exercise in the book and never did javascript before and I had no problem doing jquery. Of course if you got javascript experience it is a plus since sometimes you will be trying to find a jquery solution when javascript already has a method for what you want to do.
Edit 3
A)
The only problem is that it can be a
bit trickery to do ajax request using
jquery when using asp.net
webforms(asp.net mvc was designed with
frameworks like jquery in mind so it
is easier to do).
Are you implying that perhaps jquery
could be too much of a hassle when
used together with webforms and thus I
should think of using Asp.Net Ajax
instead?
No I am not implying that it is too much hassle for webforms was just stating the fact that it will be a bit more tricky in certain situations then ms ajax and jquery with say asp.net mvc.
asp.net webforms was not really made for a framework like jquery and has trouble dealing with it because of it's page life cycle gets in the way. MS ajax might have it's own set of challenges though too(like everything usually does). Jquery was made in mind of to try and work across all browsers since in javascript many times you would write something that worked in IE but did not work in any other browser and I am not sure if MS ajax client side version thought about this.
B) Little I read on ajax is that it
also needs to call web services or
some other technology that provides
similar functionality to web services.
If true, which technology do you use (
WCF or Asp.Net web services or … )?
Yes this is true. This was the whole point many people including me where trying to make to prove that guy was wrong that asp.net was dying because of ajax, since you need something in the back end to make a call too.
However you can choose whatever you want. You can make a separate web service( can be a asp.net web service), you can have like static web service methods in your page load ( I never done this way) and the way I use to do it is by making a generic ajax handler.
You can't however just make a regular method in your page_load and try to call it as it has to go through the entire page life cycle.
http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/
http://weblogs.asp.net/craigshoemaker/archive/2008/11/07/using-jquery-to-call-asp-net-ajax-page-methods-by-example.aspx
http://dotnetslackers.com/articles/ajax/using-jquery-with-asp-net.aspx
http://sites.google.com/site/spyderhoodcommunity/tech-stuff/usingjqueryinaspnetappswithhttphandlersashx
I have not read these tutorials but these tutorials should show you the 3 different ways you can do an ajax request to an asp.net webservice, asp.net code behind page and asp.net generic handler.
Choose what ever one you think is best. I don't know if one way is better then another and there probably are more ways to do it.
C) Is Ajax a subsection of jquery?
Thus, to understand Ajax, will I need
to purchase only a book on jquery or
will I also need to read a book with
Ajax in its title
Ajax is just part of jquery and probably won't take you long to learn. If you buy a book about jquery there will probably be like 1 chapter on it. The only down side is all the jquery books I know of are all in php.
So if your just buying it to learn the ajax part probably not worth it since they will show an entire example of how to do it with php that might be slightly different then if you did it with asp.net( mostly just setting up the server side to accept the jquery calls- see the links that I posted above).
If you want to learn jquery selectors and stuff then it does matter if the one chapter is in php since it's all client side stuff expect for the ajax part( what is client side and server side).
It's not hard to really do the ajax stuff it just knowing what path you need to choose and more how to accept stuff on the server side and return stuff from the server side.
$.post("test.php", { name: "John", time: "2pm" },
function(data){
alert("Data Loaded: " + data);
});
The above is basically all you need to do on jquery side to send some ajax stuff. The first parameter is the path where this request should go. In this case its some php file called test. The next parameter is the the actual data sent as a json result and finally the last line is the function call back line. When the ajax post request is done that line gets called and does the actions. Data is the returned stuff you sent back from the server.
http://api.jquery.com/jQuery.post/
So I would just go through the tutorials I posted and play around with the jquery selectors. Once you done that you can decide if you want to go with jquery or not. The last thing I wanted to point out about why I like jquery is the fact that if you learn the MS ajax stuff your basically stuck with asp.net( what I have no problem with since I love .Net) but with jquery you can easily take your code or those skills of jquery and use it with php, ruby or whatever else and all the client side jquery selectors won't change by switching a different language. The only thing that will be different is the ajax stuff and even that won't be 100% different as the jquery ajax client side could will be the same.
Ajax is a methodology which can be used in conjunction with with other frameworks, such as asp.net. Asp.net will allow you to integrate javascript to implement ajax solutions.
A common implementation is to use javascript to call an asp.net webservice to perform ajax operations.
Ajax is the new "old thing" - ASP.NET MVC is the new "new thing" :-)
But seriously, you can mix all of these technologies in one web application if you want:
"classic" ASP.NET (WebForms)
Ajax (using ASP.NET Ajax controls other approaches such as jQuery)
ASP.NET MVC.
AJAX is a technique essentially added on top of an existing website to allow things to be done on that page without refreshing the entire page. Here on StackOverflow, for example, you can vote by clicking the up/down arrows via AJAX, without the page refresh you'd have seen without AJAX.
It doesn't replace ASP.NET (or any other language).
AJAX does not replace ASP.NET. They can be used together or independently. ASP.NET is more of a framework, where AJAX is a set of techniques built on top of JavaScript and HTML.
There is a framework that Microsoft has called ASP.NET AJAX. There are controls that will output JavaScript so that if you wish, you can have AJAX functionality without having to get too far into JavaScript.
However, you could also write the JavaScript by hand and use XMLHttpRequests to send requests to ASP.NET URLs and get data back.
ASP.Net is primarily a server-side technology stack which dynamically generates most of the client-side code. The out-of-the-box ASP.Net 2.0 page model is a fairly painful way to implement AJAX-enhanced user interaction (though there are techniques, such as custom handlers, that make it pretty tractable). Both the ASP.Net MVC and ASP.Net AJAX frameworks provide helpful tools for making it lest troublesome.
AJAX is commonly used to describe any asynchronous, partial-page-interaction technique to build the user interface of your application.
The server-side technology and the client side technology choices are fairly independent, though different techniques for how to work with a client side technology become attractive with different frameworks on the server.

AJAX+ASP.NET

As far i learned ....AJAX is used for partial page refresh (overcoming the flickering effect in the web page) ....Is there any other features in AJAX....
Technically Yes. Ajax is used for "partial page" refresh there by eliminating the complete page refresh. There are 2 main advantages
Data transfer : Data transfer (To and from the server) is less compared to the entire page refresh
Better User experience : Since the user will not be seeing a blank page it gives the user an illusion of interacting with the site.
What can be done using AJAX is an ever ending list.
Ex: Gmail uses AJAX for it email. If you are using gmail and compare it with other email providers you will know the difference.
Facebook has rich AJAX features in its site.
SO uses AJAX for comments
I think What AJAX cannot do will be easier to mention. For example
AFAIK web browsers cannot maintain the view state of the AJAX enabled website.
Some AJAX enabled websites do not render properly in mobile browsers.
Anythign more?
Your question is a bit confusing, but you can do Ajax with ASP.NET. You can do partial page refreshes with Ajax among other things using the UpdatePanel in ASP.NET. You may also want to look at jQuery for a simpler more lightweight Ajax solution.
I think you're very mistaken. If AJAX had been created only to solve the problem of partial page refresh/page flickering, it would not have revolutionized the web in the way it has.
The single biggest advantage offerred by AJAX is Client-to-Server Communication that is initiated based on some action on the client. This instantly gives us the ability to make the web much more responsive and user friendly without users having to wait for page reloads and postbacks.
I would suggest that you spend some time researching the subject. Read up on the Wiki article on AJAX.
As far as ASP.NET is concerned, AJAX integrates very well into it. Mature AJAX frameworks such as ASP.NET AJAX and Anthem.NET obfuscate much of the internal details of the XmlHttpRequest.
Ajax has let me add some great new features to my web applications with the free Ajax toolkit. See the link
Ajax Examples
They do not come with out their issues but once you learn how to use them they can really add to the the users experience in you site.
ASP.NET uses as you know UpdatePanel for partial page refresh using AJAX.
A less known feature is something .NET calls web methods. This is really AJAX calls that is not connected to the GUI part of the page. You can declare (server-side) a method as a WebMethod, and in the client side, you can call that using JavaScript.
Example:
This example shows how to get the value of a session variable. Note that the method must be Shared - which means that it does not know of any member values on the page object.
As for all ASP.NET AJAX functionality, you need to have a ScriptManager element on the page. To enable page methods, you also need to add EnablePageMethods="true" to the ScriptManager like this:
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" />
Server side code (VB):
<Services.WebMethod()> Public Shared Function GetPreviewImages() As String
Dim lPreviewImages As String = HttpContext.Current.Session("mPreviewImages")
If lPreviewImages IsNot Nothing Then
Return lPreviewImages
Else
Return ""
End If
End Function
Client side code:
//Declare the return methods:
function GetPreviewImages_Success(result, userContext, methodName) {
alert(result);
}
function GetPreviewImages_Failed(error, userContext, methodName) {
var errorMessage = 'Error in map server method ' + methodName ;
if(error !== null) errorMessage += '\n' + error.get_message();
alert(errorMessage);
}
// Call the page method:
PageMethods.GetPreviewImages(GetPreviewImages_Success, GetPreviewImages_Failed);
See also example in C#, which also includes how parameters work in the web method.

How to use jquery form plugin with asp.net?

in asp.net 2.0 (not mvc), the form's action is to itself. how can I use the forms plugin to send information to server?
I need to send data from the form (let's say name, email, comment) and to display the result on the client side.
Any ideas?
Thanks,
Dave
ms ajax? if i use update panel, i don't need jquery. i want to use jquery and the form plugin (plus the validation plugin) only. no microsoft ajax for me, thank you!
just look at the trafic they produce in firebug to understand why.
It depends on how much of asp.net you want to use during the form submit. I am using the forms plugin in this same way but you need to think in terms of a more classic web model.
The forms plugin does a 'submit' which does not include any viewstate information. That is to say, if you try to get a value like so
sName = txtName.text
the text for txtName will be blank. But if you use your request object you should be able to pull back the value provided your know the control's UniqueID
sName = Request.Form(txtName.UniqueID)
Then what I would do is use the form plugin's success: callback to run an ajax call that will pull back your results. You can use ms ajax WebMethods for this, and you can call the webmethods directly from jquery without the need for the ms script manager. In this case, the WebMethod is returning the html I want displayed on the page.
$(form).ajaxSubmit(function(){
success:function(ret){
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: "{}",
url: "SomePage.aspx/SomeWebMethod",
success: function(msg){
$('#somediv').html(msg);
}
}
});
More info on calling ms ajax with jquery here
Because of the way viewstate is tightly coupled to the form in ASP.NET, unless you set up a service to accept the request I'm not sure if this is going to be possible. If you don't want to use viewstate, then you could just use a normal HTML form on the aspx page and submit that to a service that returns your expected results.
When you submit an asp.net form to postback, it sends everything back through the page lifecycle, I don't think there really is anything for a jQuery ajax request to talk to. You could setup a WebMethod on the page, which essentially exposes a service and you could get the jQuery request to talk to that, but I'm not conviced that it would work.
However, you can do ASP.NET AJAX with the MS libraries without using UpdatePanels, see this article for a good rundown of what you can do with WebMethods and the ajax javascript libraries
I ran into this problem today and eventually solved it using the following combination of hacks:
Suppose you have a search page and a results page and you have a form on the search page that you want to post to the results page and load via ajax using the jquery forms plugin. You need to do the following:
Create a Search.aspx page and a Results.aspx page
ASP.NET webform pages have a single form on a page with and id of aspnetForm but the action will always be set to post to itself, so the first thing you need to do when you load the Search.aspx page is to change the action of the aspnetForm to be Results.aspx like this:
$('#aspnetForm').attr('action', 'Results.aspx');
You then need to deal with viewstate so that when you POST from Search.aspx to Results.aspx you don't get invalid viewstate errors. To do this just remove the viewstate variable from the page like this:
$('#__VIEWSTATE').remove();
then you should be able to set up the #aspnetForm to use the jquery forms plugin like so:
$('#aspnetForm').ajaxForm();
This then allows you to post to the Results.aspx webform. This is just a start to get you going in the right direction, but basically it comes down to needing to change the action that the aspnet form posts to and then removing viewstate.
I currently use a mix of asp.net and jquery and the way i solved the issues with the page life cycle and such is to simply not use the autopostbacks and asp.net buttons to submit the form.
I use either ajax calls attached to simple html buttons or, when i really want to submit the entire page i use the __doPostBack(eventTarget, eventArgument) javascript function.
These articles were useful to me:
Understanding the JavaScript __doPostBack Function
Calling __doPostBack in javascript
It doesn't seem VS08 works for you, but others may be interested:
I went to a MSDN Roadshow the other day that seemed to make it very easy.
Scott Gu's blog has this:
http://weblogs.asp.net/scottgu/archive/2008/11/21/jquery-intellisense-in-vs-2008.aspx
It doesn't work, as ASP.NET force you to put everything within a server form as long as you use server control (this is the way how it handles postback). The primary problem you would have is HTML does not allow nested form anyway, so you can't even use jQuery to find the form element (thats my experience with FF3)
The good answer (but hard to achieve)- throw away WebForm and use MVC.
The compromise workaround- I did a small plugin myself which converts a div into an ajax submit with the div abused with method="post" and action="url" dress up, then utilize jQuery Form Plugin to serialize, submit with a plugin pattern. It doesn't do File Upload though (as that requires IFrame, I think its still feasible, but take some more hack). The code is in my client's project so I still dont have permission to post it as a plugin. However I think this is not too hard to do it once you know the theory :)
Really, aim for the good answer (get rid of WebForm) next time. Its not just jQuery Form going to hurt you, there's a lot more pain you have to take if you decided to do jQuery + Web Form, if its not my client's requirement I would never take this path.

Resources