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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Life Cycle problem

Status
Not open for further replies.

bereza

Technical User
Jun 14, 2006
105
EU
Hi,

I dont know how I explain my problem. I have used VeiwState to save value of a control.

Here is what I have done

Sub Page_Load
If (Not Page.IsPostBack) Then
the view state declared and get a value
end if
end sub

Sub Page_PreRenderComplete
If MyViewState = "yes"
MyButton.text = "Add"
Else
MyButton.text = "Cancel"
End If
End sub

I had to do this because every time the page loads it changes MyButton.Text to "" . for example first i did wrote this code in the MyButton_Click event but when the page loads it changed back to "".

Now the problem is, even if another events happend it goes in i PreRender and changed the text of my button, I want mybutton changes its button just when i click on

How?

thanks for your help


 
>>Now the problem is, even if another events happend it goes in i PreRender and changed the text of my button, I want mybutton changes its button just when i click on

write the above code in the button_click event?

but from what you say, looks like the viewstate is not working right? in that case can you check the page's or the button's viewstate settings???

Known is handfull, Unknown is worldfull
 
Thanks,

Actually I have not understand ViewState, how you use viewstate of a control, How and when you use the page's ViewState?

have you possibility to explain a little what is differences?

thanks a lot
 
in ASP.NET whenever the page post backs the fields retain their original values right. e.g: dropdown values are retained when some other event (like datagrid events occur) even though you populate the dropdown only once (using IsPostBack check).

how does this work?

ASP.NET uses a concept called ViewState to manage this. It uses a hidden field called __VIEWSTATE to save the data from the fields. this view state is preserved over post backs...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top