Thanks Karl,
It did the trick, but it still confuses me (the client / server /
session thing).
I know that's what it's all about but I just don't get it..
In vb.net I just say
car.speed = 50
start car
'car.started = true
'car.speed = 50
In asp.net I have to start the car (By pressing the start button =
postback my speed resets), I have to store the speed in a ViewState.
If I catch the speed viewstate in In the page_load event it's empty
because the 50's assigned in the btn_start click event and the
Page_load event's triggered before speed gets it's value.
If I want to do something with the ViewState I have to retrieve the
values in the Pre_Render event..
Private Sub Page_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.PreRender
Panel1.BackColor = ViewState("BackColor")
End Sub
It seems like ASP.net is much more complicated...
But anyway thanks for your help it helped me a lot.
Regards,
Mike
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:<e6**************@tk2msftngp13.phx.gbl>...
Your subject says UserControl (ASCX files), but this is a server control
question (no problem, just wanted to make sure the terminology was
straight).
There's nothing wrong with your code, if you want the value to be persisted,
you need to store it in the viewstate as you did...there are no alternative,
unless you reset the value on postback in your page...your proprety should
probably look something like
public property Tag() as string
get
if ViewState("tag") is nothing then
'What to do? return default maybe?
else
Return cstr(ViewState("tag"))
end if
end get
set (byval value as string)
ViewState("tag") = value
end set
end property
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/