Whenever you use a Button or LinkButton it is because you want to be able to do a
postback when it is clicked. The same could be the case for CheckBox or DropDownList
etc. but then you need to set the AutoPostback property to true. It all works very
much the same way from a user’s point of view - click or select and the page performs
function that emulates the click of an e.g. LinkButton. That is very simple to do
so, but did you know that you also can send custom information via such a postback?
The following LinkButton calls the server-side event handler OnSaveClick.
<asp:LinkButton runat="Server" ID="btnSave" Text="Save" OnClick="OnSaveClick" />
This is pretty much standard and no tricks have been used so far. Now we need the
Notice that the function takes a parameter that it sends to the __doPostBack function.
Now the page performs a postback and we can now access the “Hello world!” string that
we sent as a parameter from within the OnSaveClick event handler.
protected void OnSaveClick(object sender, EventArgs e)
a parameter to the server-side event handler. It sounds a lot harder than it is, right?
In ASP.NET 2.0 you have to set the EnableEventValidation="false" attribute
in the page declaration or in web.config to make it work.* $4.95/month ASP.NET Hosting with FREE SQL 2012 DB! – Click Here!