Sunday, July 22, 2012

How to use autopostback in asp.net ?


  • AutoPostBack is built into the form-based server controls, and when enabled, automatically posts the page back to the server whenever the value of the control in question is changed. Because of the additional server requests it causes, it's not something you'll want to enable for all your controls, but for things that affect page display or change choices further down the form, it can be really handy. Not to mention the fact that it will save you a lot of time and headaches over trying to implement something similar on your own. Not that it's really all that complex to do on your own if you're good with javascript, but it's hard to get any simpler then just setting

    AutoPostBack="True"
    
    
  • AutoPostBack is a feature that is availabel on a few controls,the main purpose of it is that if any change happened on a control by the client,it should postback to the server to handle that change at serverside,handling that change at serverside could be for many reasons i.e storing a value to DB,make changes to the page depending on it,..etc
i.e. You have a dropdownlist that has items (department names for example),if a user selected a department,depending on selected item you want to fill a gridview (fill all the employess of that department),as you can see,what must be shown at the gridview depends on what the user selects from the dropdownlist,this is the general concept,right now I don't have a code example on that,but I have link to a simple example but it's not different than the general concept I menthioned(in the example,instead of changing the label text,you can connect to DB,fetch records then fill it to a gridview

No comments: