I know that Aspnet web form are kinda old school now a days with MVC 3 in the picture, but I wanted to share a way I have used in all my project to increase productivity. There are .cs codebehind pages that you use in a every aspx file that you always have to deal with postback.
A great way to not waste time typing the same code over and over again is to use snippets in visual studios.
One that I use on just about every page that has code behind is this series of syntax:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
}
}
protected void Page_Init(object sender, EventArgs e)
{
}
This handles postbacks in your page and sets up the on page initialize, in which you can use to wire up events for your buttons, dropdownlists, datagrids, dataviews, ect.
Here is my snippet to use at your own discretion, I asked that you please dont modify the author out of personal copyright credit.
Snippet:
http://bit.ly/yUzGBp
Just unzip snippet and drop it in the directory listed below. Then when in your codebehind (.cs file) simply type:
“pageload” then hit the TAB Key twice.
Installation path: “C:\Users\ahicksdev\Documents\Visual Studio 2010\Code Snippets\Visual C#\My Code Snippets”
Feel free to post any snippets that you have found useful in your development experience.
Thanks in advance for sharing! :)