Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

prevent user control from postback

Status
Not open for further replies.

IT4EVR

Programmer
Feb 15, 2006
462
US
Is there a way to prevent a user control from posting back? I'm generating dynamic content on the user control but whenever I postback on the parent form, naturally it's posting the user control. I'm dynamically manipulating treeview nodes client side in javascript.

I read somewhere that you could facilitate this with IFRAMES or a hidden frame, but not sure how to create this functionality.

Or maybe there is another method that will work.
 
If you are modifying the content of the page through javascript, you'll have to post those changes to the server and then replicate them otherwise the page will be sent back in it's original format (as you are probably seeing). You can post those changes a few ways, one of which is to use hidden variables.

Also, don't forget that in your user control, you can use Page.IsPostBack to check whether the page is being posted back or not.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Can you show me how I would post these changes back to the server? You're right, I add or rearrange nodes and then I lose the changes.



Thanks...
 
Well, I'm assuming you have some kind of function that allows the user to add some dynamic content to your user control.
Code:
<input type="hidden" id="myDynamicContent" value="" />
If you include a control like the one above, when you add the content to the control, also set the value of the hidden element. This way the content will be posted back to the server. Your user control then just reads this hidden value and recreates the changes.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top