views:

76

answers:

2

I have a Page, containing an UpdatePanel and a Usercontrol which loads another usercontrol, containing a textbox.

So it's Page->UpdatePanel->UserControl->UserControl (B)->Textbox

The ValidationGroup for the button and textbox is the same. I call .validate("answer") in the codebehind, I'd rather not use the JS validation. If the button is clicked, the value in the textbox is cleared and the error displays, but only on the first click. After that it works fine, but then a different UserControl (B) with the same same setup. The same happens again, on the first click. If I fill in the value again, it stays and I get a postback.

This is bizarre and I can't think what would cause it, if I add the button as a postbacktrigger (ie: remove the updatepanel), it works normally. I've tried setting CausesValidation on the button with no effect and I'm out of ideas.

A: 

Are you sure your not clearing the value of the textbox in your code somewhere?

Can you put up some code for us to take a look at?

bechbd
It's difficult because there's so much code. UserControl (B) is created dynamically onpostback, and the first time it's value is null for some reason. I don't understand why it's only the first time though c.
Echilon
A: 

This was actually caused by the ID of UseControl (B) changing between the first and subsequent postbacks. The ID needs to stay the same I think for the ViewState to populate back.

Echilon