How to disable AutoPostBack for a button in ASP.NET?

  • Thread starter Thread starter Sean M
  • Start date Start date
S

Sean M

Guest
I don't want this button to post to the server when clicked but that's the default behavior. The reason is I am learning about adding objects to view state and it keeps posting back when I click but all I want it to do is add the object.

Also, do you have any idea why I have to click the button twice for it to add the object to view state? I put the code to add the object inside the on_click method for the button but it doesn't add the object until I click the button TWICE!

Any ideas?
*Maybe the reason it isn't posting until the second time is:

server --> browser (no view state yet)
server <-- browser (no view state yet)
server --> browser (view state)

something like that? HELP ME! O DEAR GOD HELP ME!
Okay to have it update on the first button click you place the code to add the object inside the Page_PreRender method.

I'm still not crystal clear on why other than it has something to do with the order in which things are done but it works.
 
Back
Top