Value set , is refelcted in next postback

aideveloper

Newcomer
Joined
Mar 7, 2010
Messages
1
I have a Dropdown with two values "P" and "Q" with
AutoPostBack= true. I have another Custom WebControl called BDTextBox, this custom textbox have a Boolean property called LabelMode , on setting it to true would render the textbox as label.This LabelMode Property is set using ViewState and not using private variable.


my need is that if Dropdown has value "P" the labelmode = false and on "Q" labelMode = true; my code looks somewhat like this.

I have tried writting this code in PanelCreation , OnPrerender but there seems to be a issue with it.

As i hit this code and suppose Dropdown value is "P" , it goes in if loop and as per code it sets value as false, that means it is not rendered as label.
But after the page is loaded completely it is rendered as label still that it has value of true in it.
Code:
     If(Dropdown.selectedvalue="P")
      {
        BDTexTbox.LabelMode = false;
      }
       else
      {
        BdTextBox.LabelMode = true;
      }

Now if i change the Dropdown value to "Q" , it again hits code it goes in else loop and sets value of "true", but after page loads it is not rendered as label.

What is noticed that the value set is reflected in next postback. If if i set value as true and previously it was false, so once page is loaded it picks up older value and not which is set at runtime.

How the value set at runtime can be made to refelect in page in same postback itself ? why it reflects in next postback ? I guesss its somehting related to viewstate.
 
Are you generating the viewstate on the autopostback but creating the controls in the page_load?

If so you are processing the page load before you are changing the viewstate, you might want to also manage the UI changes from the autopostback event as well.
 
Back
Top