cache or delay postback?

  • Thread starter Thread starter Rubble
  • Start date Start date
R

Rubble

Hello,

Ive placed a server control button on my aspx page. Ive created some
client side script that Ive tied to the onclick action of this button.
The script adds to a listbox the contents of a textbox. It works
very well, but the page does a postback, and the listbox resets
itself.

The listbox has to be a server control, so I cant create this whole
scenario using your basic client side javascript.


How can I stop the postback...or cache it for later...or in some way
keep the page from reloading? Can I build an html button and tie the
server listbox control to it?

Any ideas would be appreciated.

Thank!
B. Rubble
 
Rajesh.V said:
Add return false; after your js tied to onClick. This should arrest the
postback. If you want the added items to persist then the same shud be added
to a hidden text box and added to the list whenever the postback happens.



That sounds easy enough! Thanks for the suggestion, Ill try it out
later. I thought that it would have to be some asp.net setting since
a server button control would always post back to the server, no
matter what the action was it performed.

On a similar note...can anyone show me how to get values from an html
control on the code behind? If I place the values in a hidden text
box, Ill have to pull them when I process the page. I know how to do
this in old asp...but how do I do it in asp.net?

thanks again!
 
Add return false; after your js tied to onClick. This should arrest the
postback. If you want the added items to persist then the same shud be added
to a hidden text box and added to the list whenever the postback happens.
 
After u place the htmlcontrol, right click and choose run as server control.
Then you can access the same in code behind.
 
Back
Top