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.

If(Dropdown.selectedvalue="P") 
 {
    BDTexTbox.LabelMode = false;
 }
 else
 {
    BdTextBox.LabelMode = true;
 }

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.

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.

Recommended Answers

All 2 Replies

Use like this and let me know,

If(Dropdown.selectedvalue=="P")

Use like this and let me know,

If(Dropdown.selectedvalue=="P")

sorry , that's what it is. it was typo error.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.