Should i worrie?

  • Thread starter Thread starter Edwin Knoppert
  • Start date Start date
E

Edwin Knoppert

I read that i should use the viewstate to store properties for a
usercontrol.
But what will happen when i have 2 or more instances of this usercontrol on
the same webpage?

Is the ViewState able to make unique instances for me, i don't think so..

I'm looking for the "how it should" way..
 
Maybe if you use the "this" (C#) or "me" (vb) keyword? Then I would asume that it would behave(?)...

Martin Gregersen
WebShine A/S
(e-mail address removed)
I read that i should use the viewstate to store properties for a
usercontrol.
But what will happen when i have 2 or more instances of this usercontrol on
the same webpage?

Is the ViewState able to make unique instances for me, i don't think so..

I'm looking for the "how it should" way..
 
Indeed!

i just tested two control instances and they remain having unique values.
The example in the help is ok:

public String Text
{
get
{
object o = ViewState["text"];
return (o == null)? String.Empty : (string)o;
}

set
{
ViewState["Text"] = value;
}
}

"Martin Gregersen" <[email protected]> schreef in bericht
Maybe if you use the "this" (C#) or "me" (vb) keyword? Then I would asume
that it would behave(?)...

Martin Gregersen
WebShine A/S
(e-mail address removed)
I read that i should use the viewstate to store properties for a
usercontrol.
But what will happen when i have 2 or more instances of this usercontrol on
the same webpage?

Is the ViewState able to make unique instances for me, i don't think so..

I'm looking for the "how it should" way..
 
Ya. It's pretty smart. Always appends the control's id to the property. You
can easily see this by enabling page tracing.

Also, if you write your own custom server control, if you implement
INamingContainer (no methods are required), it'll take care of it for you
too.

Karl
 
Ya. It's pretty smart. Always appends the control's id to the property.
Huh?
I just stated that the viewstate values remain unique by itself.
Iow, no need to add unique id's manually.
Or did i misunderstood your post?

The code i use below should imo be sufficient.

Please correct me if i'm wrong.

Thanks,



"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> schreef in bericht news:[email protected]...
Ya. It's pretty smart. Always appends the control's id to the property.
You can easily see this by enabling page tracing.

Also, if you write your own custom server control, if you implement
INamingContainer (no methods are required), it'll take care of it for you
too.

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/


Edwin Knoppert said:
Indeed!

i just tested two control instances and they remain having unique values.
The example in the help is ok:

public String Text
{
get
{
object o = ViewState["text"];
return (o == null)? String.Empty : (string)o;
}

set
{
ViewState["Text"] = value;
}
}

"Martin Gregersen" <[email protected]> schreef in bericht
Maybe if you use the "this" (C#) or "me" (vb) keyword? Then I would asume
that it would behave(?)...

Martin Gregersen
WebShine A/S
(e-mail address removed)
I read that i should use the viewstate to store properties for a
usercontrol.
But what will happen when i have 2 or more instances of this usercontrol
on
the same webpage?

Is the ViewState able to make unique instances for me, i don't think so..

I'm looking for the "how it should" way..
 
That's all I was saying...ASP.NET is smart, it takes care of it for you :)

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/


Edwin Knoppert said:
Ya. It's pretty smart. Always appends the control's id to the property.
Huh?
I just stated that the viewstate values remain unique by itself.
Iow, no need to add unique id's manually.
Or did i misunderstood your post?

The code i use below should imo be sufficient.

Please correct me if i'm wrong.

Thanks,



"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> schreef in bericht news:[email protected]...
Ya. It's pretty smart. Always appends the control's id to the property.
You can easily see this by enabling page tracing.

Also, if you write your own custom server control, if you implement
INamingContainer (no methods are required), it'll take care of it for you
too.

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/


Edwin Knoppert said:
Indeed!

i just tested two control instances and they remain having unique
values.
The example in the help is ok:

public String Text
{
get
{
object o = ViewState["text"];
return (o == null)? String.Empty : (string)o;
}

set
{
ViewState["Text"] = value;
}
}

"Martin Gregersen" <[email protected]> schreef in bericht
Maybe if you use the "this" (C#) or "me" (vb) keyword? Then I would
asume that it would behave(?)...

Martin Gregersen
WebShine A/S
(e-mail address removed)
I read that i should use the viewstate to store properties for a
usercontrol.
But what will happen when i have 2 or more instances of this usercontrol
on
the same webpage?

Is the ViewState able to make unique instances for me, i don't think
so..

I'm looking for the "how it should" way..
 
Thank you :)

"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> schreef in bericht news:%[email protected]...
That's all I was saying...ASP.NET is smart, it takes care of it for you :)

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/


Edwin Knoppert said:
Ya. It's pretty smart. Always appends the control's id to the property.
Huh?
I just stated that the viewstate values remain unique by itself.
Iow, no need to add unique id's manually.
Or did i misunderstood your post?

The code i use below should imo be sufficient.

Please correct me if i'm wrong.

Thanks,



"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> schreef in bericht news:[email protected]...
Ya. It's pretty smart. Always appends the control's id to the property.
You can easily see this by enabling page tracing.

Also, if you write your own custom server control, if you implement
INamingContainer (no methods are required), it'll take care of it for
you too.

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/


Indeed!

i just tested two control instances and they remain having unique
values.
The example in the help is ok:

public String Text
{
get
{
object o = ViewState["text"];
return (o == null)? String.Empty : (string)o;
}

set
{
ViewState["Text"] = value;
}
}

"Martin Gregersen" <[email protected]> schreef in bericht
Maybe if you use the "this" (C#) or "me" (vb) keyword? Then I would
asume that it would behave(?)...

Martin Gregersen
WebShine A/S
(e-mail address removed)
I read that i should use the viewstate to store properties for a
usercontrol.
But what will happen when i have 2 or more instances of this
usercontrol on
the same webpage?

Is the ViewState able to make unique instances for me, i don't think
so..

I'm looking for the "how it should" way..
 
Back
Top