ASP.NET PostBack event

In ASP.NET, 1 new thing being implemented is called the PostBack event. This is an event triggered whenever there's a response from a user that will need immediate action to be taken on the server side, either be a redirection or disabling some interface control.

This is a welcoming event for me because I know how hard it is to make a web page to be user friendly, especially when I need to make all the buttons to be disabled when certain selection is done in JavaScript. It is pretty difficult for me and sometimes certain JavaScript codes don't work on certain browsers. With this PostBack event, I could just write everything in the back end codes instead.

Of course, there are some drawback to use the PostBack event as I'd assume, because everytime a PostBack is triggered, the page will be reloaded with the Page_Load event, and there's a communication being made with the server, so the server will be heavily loaded. The thing is, though the server will be heavily loaded, with the current bandwidth and server performance, this has become not relevant. Of course, interface changing with JavaScript on client side reduces the number of connections make to the server, but the sad thing is that as far as I work with ASP.NET, I can't make JavaScript to work with the ASP.NET controls. So, if I am going to use ASP.NET controls to the fullness, I will have to stick with this PostBack event and have to sacrifice JavaScript.

1 thing with PostBack event, is that it will load everything in Page_Load event. This means that whenever there's a PostBack to the server, the Page_Load will be fired first, and if the code in Page_Load is not carefully written, I may not get the desired result. This is what I experienced with the drop down list control box. I wrote in the Page_Load to data bind a drop down list control box to a data source, then I have an event fired whenever there's a change in the selected index, which will respond by showing me the index and value of the selected item; yet instead of that, it always shows me the index and value of the first item in the list.

In order to avoid the above, I found out that there's a property called IsPostBack that could be used to handle the above situation in Page_Load. It is a property that will be flagged to true if there's a PostBack event being triggered, thus with this, I could bypass the code in Page_Load.

Comments

Popular posts from this blog

Yahoo! Messenger voice call & video call disabled, why?

Sport's Injuries - Treatment for bruises

Web Development: Disable, Validate, & Enable Buttons