473,395 Members | 1,411 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 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 3335
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Christian | last post by:
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...
0
by: Christian | last post by:
Hi, I try to change the position of a WebUserControl on my WEbform (layout is set to GridLayout) by changing the absolute position in the html-code but it does not work. When I change the...
3
by: Andreas Klemt | last post by:
Hello, how can I clear all ViewStates from a WebUserControl without doing a PostBack ? Thanks in advance, Andreas
3
by: Steve Drake | last post by:
All, I have a CONTROL that contains 1 control (Control ONE), the 1 control that it can contain 1 or 2 control (Control A and B). Control A, raises and event and Control ONE receives this event...
7
by: et | last post by:
I'm not sure I understand the use of the ViewState. Do I understand correctly that values of controls are automatically held in a hidden control called ViewState? If so, then why can't we get...
0
by: bminder | last post by:
I have a web user control that contains a serializable class. I persist this class in viewstate, but on postback, the viewstate is null. Is this behavior by design? This technique works fine on...
0
by: Giovanni | last post by:
Dear Friends, I have a decision to make and hope to get some insight: I have built several WebUserControls one of which is a WebUserControl that queries an SQL server database, retrieves a...
1
by: robert112 | last post by:
Hi All, I have a webpage.aspx and a webusercontrol.ascx with both of them having viewstate turned off. Then in my web user control I have got some code reading the request stream: Dim str As...
1
by: robert112 | last post by:
Hi All, I have a webpage.aspx and a webusercontrol.ascx with both of them having viewstate turned off. Then in my web user control I have got some code reading the request stream: Dim str As...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.