472,127 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

Viewstate of WebUserControl does NOT work

Hi,

Viewstate of WebUserControl does NOT work although the
'EnableViewstate'-property of the usercontrol is set to true

Description :

Using ASP.Net :
I have a created a WebPage with 2 buttons and 1 Web-UserControl of type
LottoWebUserControl. The control has 1 label-control embedded

The purpose is to toggle the visible-property of the embedded-label-ctrl
using the 2 buttons:

Some sample code :

public class LottoWebUserControl : System.Web.UI.UserControl
{
private void Page_Load(object sender, System.EventArgs e)
{
if ( ! IsPostBack )
MyVisible = false;
else
MyVisbile = (bool)ViewState["visible"];
}
public bool MyVisible
{
get { return (bool)ViewState["visible"]; }
set
{
ViewState["visible"] = value;
SetState();
}
}
private void SetState()
{
lbl1.Visible = (bool)ViewState["visible"];
}
}

// The Web-Page containing the 2 buttons and an instance of the usercontrol
// 'EnableViewstate'-property of the usercontrol is set to true
public class WebForm1 : System.Web.UI.Page
{
protected LottoWebUserControl m_LottoWebUserControl = new
LottoWebUserControl();

private void button1_Click(object sender, System.EventArgs e)
{
m_LottoWebUserControl.MyVisible = true;
}
private void button2_Click(object sender, System.EventArgs e)
{
m_LottoWebUserControl.MyVisible = false;
}
}

The toggling does NOT work. The label-ctrl remains in one state.

Maybe a clue : ViewState["visible"] has a correct value when used in the
Page_Load() handler but when accessed in the set-part of MyVisible-property
has it a value of null (before ViewState["visible"] = value; is executed)

any ideas ?
thanks

Chris

Jul 19 '05 #1
5 3284
Christian wrote on 15 jul 2003 in microsoft.public.inetserver.asp.general:
Viewstate of WebUserControl does NOT work although the
'EnableViewstate'-property of the usercontrol is set to true


this is a classical ASP ng !

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #2
Evertjan wrote : "this is a classical ASP ng ! "

ok, but then again.
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
Christian wrote on 15 jul 2003 in microsoft.public.inetserver.asp.general:
Viewstate of WebUserControl does NOT work although the
'EnableViewstate'-property of the usercontrol is set to true


this is a classical ASP ng !

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Jul 19 '05 #3
Christian wrote on 15 jul 2003 in
microsoft.public.inetserver.asp.general:
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
Christian wrote on 15 jul 2003 in
microsoft.public.inetserver.asp.general:
> Viewstate of WebUserControl does NOT work although the
> 'EnableViewstate'-property of the usercontrol is set to true


this is a classical ASP ng !


ok, but then again.


If you wish:

"this is a classical ASP ng !"

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #4
Christian wrote:
Evertjan wrote : "this is a classical ASP ng ! "

ok, but then again.

OK, how about this?

This is a classic asp newsgroup. While you may be lucky enough to find a
dotnet-savvy person here who can answer your question, you can eliminate the
luck factor by posting your question to an appropriate group. I suggest
microsoft.public.dotnet.framework.aspnet.

HTH,
Bob Barrows
Jul 19 '05 #5
Yeah, and stop making us feel bad. The poor us, who are stuck with "classic"
ASP :(

:)
"Bob Barrows" <re*******@yahoo.com> wrote in message
news:ul**************@TK2MSFTNGP10.phx.gbl...
Christian wrote:
Evertjan wrote : "this is a classical ASP ng ! "

ok, but then again.
OK, how about this?

This is a classic asp newsgroup. While you may be lucky enough to find a
dotnet-savvy person here who can answer your question, you can eliminate

the luck factor by posting your question to an appropriate group. I suggest
microsoft.public.dotnet.framework.aspnet.

HTH,
Bob Barrows

Jul 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Christian | last post: by
3 posts views Thread by Steve Drake | last post: by
7 posts views Thread by et | last post: by
reply views Thread by Giovanni | last post: by
1 post views Thread by robert112 | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.