views:

713

answers:

3

I am trying to access the Text property of a textbox from a partial postback-done in an Update Panel. The problem is that this textbox I want to access is not in this Update Panel, and when I am trying to write to it (putting content in the Text property), this new content is not being displayed.

I think that this is because this textbox is not part of the Update Panel's, but I'm not sure about it. And also, I cannot put this Textbox in the same update panel as the one I'm triggering a partial postback.

Why isn't the text being displayed?

+1  A: 

I don't think you can, unless you put the text box in a second update panel with the update mode set to Conditional. Then you invoke the update method or set the first update panel as an asyncpostbacktrigger to the new one.

Brandon
+4  A: 

During a partial page rending only controls contained within an update panel will have thier html refreshed. The rest of the page will remain the same.

For your specific case you would need to wrap your text box in an update panel, then you hnave a decision to make. You can either mark its UpdateMode as Always or Conditional. If you mark it as always then all the controls contained within that update panel will get updated durning every partial rendering. If you mark it conditional then you will need to call the update panels Update() method to have it's html refreshed.

Daniel
A: 

What you are trying to do cannot be done unless you put the textbox in question inside another update panel.And if you want to use the contents of your textbox under other events then set the updatemode for the new updatepanel to always. But if you want to access its Text property only during the event which is the trigger for your other update panel then set the updatemode to conditional and also set the triggers of both the panels as same...

If you are not sure about triggers and updatemode (basically how it works) then just set updatemode to always in both updatepanels and forget about the triggers. It will work fine then...