ASP.NET - Page Postbacks and event handling - asp.net

Can anyone suggest me good reading materials on the internals of how ASP.NET handles page postback and events?
-Justin Samuel.

I would absolutely read Microsoft's primer on the ASP.NET page lifecycle. Knowing the page lifecycle well will save you many headaches!

Please see How postback works in ASP.NET:
In this article, we will take a closer
look at how ASP.NET pages post back to
themselves, and how to customize this
feature in our web applications.

If you are just learning ASP.NET, check out ASP.NET MVC as an alternative which will make a lot more sense coming from other web platforms and doesn't have the added abstraction of events, state, and postbacks which http wasn't exactly designed to have.

Try to read these articles:
https://web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-10878_11-1045191.html
http://www.w3schools.com/aspnet/aspnet_events.asp
http://www.dotnetspider.com/resources/15190-ASP-NET-Page-Life-Cycle.aspx

Related

ASP.NET Web User Control(C#)

Can anyone help me in working with (multiple)WebUserControls.
I have tried, but I am not clear with the events which we have to use.
The most important thing to understand is the ASP.NET Page life cycle. Once you learn the order of operations for how an httpRequest is received into ASP.NET and how the httpResponse is built and returned you have the essential information.
This might answer your Q sharing controls across multiple websites
check this too

Is the single <form runat="server">-element requirement really necessary for ASP.NET WebForms?

Looking at some of the changes coming to WebForms in ASP.NET 4.0 I can see many improvements that give developers even more control over the output. Some of these improvement have been a long time coming, and for some time it seemed that it wasn't even possible. It made me wonder if the current model with the single form element that runs on the server is really the only possible way.
Why couldn't the ASPNET WebForm architecture work with multiple forms that all run on the server?
Imagine if you could architect this change. How would it impact the way we write codebehind today? Would it introduce extra complexity? Would it change the way event handlers work, or validation, or ASP.NET Ajax with the ScriptManager and UpdatePanel controls?
I think .NET mvc is MS making the change you speak of.
From a ASP.NET book Im not going to mention because I'm not sure if I'm allowed to, it says that before with ASP you could put 2 forms in the same page so some people in the same webpage could put a form for authentication for registered users and a form for creating an account for new users, something you cant do in ASP.NET because of the limitation of the framework. So you should be able to do that again if they would add that possibility in ASP.NET
You can toggle forms very easily on the page level:
http://www.codersbarn.com/post/2008/03/08/Solution-to-ASPNET-Form-PayPal-Problem.aspx

Resources for What and how NOT to use ASP.NET AJAX?

It's very easy to put an UpdatePanel and have AJAX working.
I am looking for resources on how to best use ASP.NET AJAX for maximum performance and security. Resources for best practices, guidance, design patterns, gotachas, pitfalls when using ASP.NET AJAX.
I am not looking for books on ASP.NET AJAX. Amazon lists those.
I really like Dave Ward's stuff on using jQuery and Asp.Net Ajax in unison. Especially his article on Why Asp.Net Ajax Update Panels are dangerous.
From the maximum performance angle, check out ASP.NET Ajax Under-the-hood Secrets, on Codeproject.com.
Subtitled "Performance tips and hard-core tricks that change core runtimes, not for the faint-hearted" it's about "the advantages and disadvantages of Batch calls, Ajax call timeouts, browser call jam problems, ASP.NET 2.0's bug in web service response caching, and so on."
It's a little over my head, but it might be relevant to what you're looking for. Since it's written by Omar Al Zabir, the guy who did Pageflakes, I think we can assume that it's solid advice.
Dino Esposito's two part article on MSDN Magazine is worth a read, AJAX Application Architecture Part 1 and Part 2. Covers some interesting topics including:
Optimization Techniques for Partial Rendering
Weighing Partial Rendering
Flavors of Services
JSON Versus XML
Security Concerns

Most stable solution for doing AJAX with ASP.NET as a backend?

I'm planning a ASP.NET project for which I'm going to use AJAX. I'm researching all the available technologies for doing so in the .NET world.
I need a solution that is well documented and stable.
The current solutions I've found are:
1. ASP.NET AJAX UpdatePanel
2. ASP.NET AJAX with Web Services + JQuery
3. JQuery + Http Handlers
In the second and third solutions the backend would only send JSON or XML messages to the client.
In my experience the best way to go is JQuery with WCF with JSON webservices.
The reason is:
ASP.NET ajax is gives you alot for free in terms of coding but is bloated from the start and needs to be stipted and slimed. On the other hand you have JQuery that you needs more development but is light weight. JQuery has a great plugin library as well.
XML is to slow, JSON is fast.
Thats how I would do it today.
All will work but I've had most performance and stability with using JQuery and a script service.
An update panel will work but as its designed to work in the general case it can be a little bloated if you aren't careful. One reason being is that it posts the viewstate back with each update.
I recommend you check out the site: encosia.com as it has a number of posts on how to use script services and page methods. Then you can make a more informed decision. I would say that I've not used page methods and probably won't but that's entirely for personal reasons.
One other thing to consider will be any mvc you may end up doing. The general consensus is that it's a whole lot easier with JQuery. Added to that Microsoft have officially adopted it and also provide intellisense in VS2008.
All compelling reasons to include at least some of it in your project. In mine I only use the built in ScriptManager when I absolutely have to.
HTH!
S

ASP.NET webforms without javascript

Due to a security requirement all browsers that will run a web application we need to create must have all client side scripting disabled. So that means no Javascript.
Unfortunately Web Forms make quite some use of Javascript. The login control works without Javascript, but a button does not (it calls the Javascript function __doPostback()).
So to make it work we'd need to program all the forms by hand (the ASP Classic, or PHP method). But I was wondering if there is a framework available for ASP.NET that offers the normal ASP.NET controls (treeview, gridview, etc) with all the functoinality they have, but that doesn't use Javascript and doesn't require the programmer to program massive amounts of logic?
Update:
For clarification, I know ASP.NET MVC is an option that will help a bit, but it won't give me a nice GridView. So I'm wondering if there is a 100% functional, 100% no-javascript replacement for the standard ASP.NET controls.
Thanks.
Update2:
It's been a while and I never found the exact answer I was looking for. Probably because what I want doesn't exist. So I'll go for ASP.NET MVC which is the next best thing.
ASP.Net MVC is probally the closest you'd get. You can use it to build a site without javascript. It is very different from Web forms
Many of the stock controls will be problematic. They just depend too heavily on Javascript. You do have some options, though:
ASP.Net MVC should give you a bit more control over your html
You can build your own replacement WebForms control library that doesn't rely on javascript to provide alternatives for controls that do.

Resources