473,785 Members | 2,188 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PRB: Webcontrol Property Lost On Build

I have a webcontrol that has the following property defined:

<Category("Beha vior"), PersistenceMode (PersistenceMod e.Attribute), DesignerSeriali zationVisibilit y(DesignerSeria lizationVisibil ity.Content)> _
Public Property ForceDeterminat eState() As Boolean
Get
Return CBool(Me.ViewSt ate("ForceDeter minateState"))
End Get
Set(ByVal value As Boolean)
Me.ViewState("F orceDeterminate State") = Value
End Set
End Property

Now, I have lots of other properties like this on my control, and they all serialize just fine to the ASPX file and to the viewstate. This one, however, loses its value whenever I build the project.

Neither the PersistenceMode Attribute nor the DesignerSeriali zationVisibilit yAttribute seems to have any effect whatsoever.

What am I doing wrong?

Thanks in advance,

Mike
Nov 19 '05 #1
1 1127
In <20************ ********@news.e ast.cox.net> Mike Hofer declaimed:
I have a webcontrol that has the following property defined:

<Category("Beha vior"), PersistenceMode (PersistenceMod e.Attribute),
DesignerSeriali zationVisibilit y(DesignerSeria lizationVisibil ity.
Content)> _ Public Property ForceDeterminat eState() As Boolean Get
Return CBool(Me.ViewSt ate("ForceDeter minateState"))
End Get
Set(ByVal value As Boolean)
Me.ViewState("F orceDeterminate State") = Value
End Set
End Property

Now, I have lots of other properties like this on my control, and they
all serialize just fine to the ASPX file and to the viewstate. This
one, however, loses its value whenever I build the project.

Neither the PersistenceMode Attribute nor the
DesignerSeriali zationVisibilit yAttribute seems to have any effect
whatsoever.

What am I doing wrong?

Thanks in advance,

Mike


I found the problem. The fix is as follows:

#Region "ForceDetermina teState"
<Category("Beha vior"), _
DefaultValue(Tr ue), _
Description("De termines whether or not the user can set the checkbox's
state to Indeterminate via mouse click."), _
DesignerSeriali zationVisibilit y(DesignerSeria lizationVisibil ity.
Content), _
PersistenceMode (PersistenceMod e.Attribute)> _
Public Property ForceDeterminat eState() As Boolean
Get
If Me.ViewState("F orceDeterminate State") Is Nothing Then
Return True
Else
Return CBool(Me.ViewSt ate("ForceDeter minateState"))
End If
End Get
Set(ByVal Value As Boolean)
Me.ViewState("F orceDeterminate State") = Value
End Set
End Property
#End Region

Turns out that when the program starts, there's no viewstate for the
property. I had assumed that the property would be set when the control
loaded, based on the settings in the ASPX file. This is apparently not
the case. However, the fix above worked beautifully.
Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1311
by: Matze | last post by:
I have a function that has an Argument of type System.Web.UI.WebControls.WebControl. I want to set the text-property of that control. Of course it doesnt work if I cast that control to (WebControl), because WebControl doesnt have a property Text. Most Controls that inherit WebControl have text so I guess there must be an common Interface implemented, but cant figure out what it is. Goal would be something like: private function...
0
1763
by: Harry F. Harrison | last post by:
Here's the situation...Context - Using an Inherited WebControl object as a base for server custom controls. In a web custom control, whenever I create a child control and add it to the Controls class, it takes 3 lines of code. Example: Dim TextBox as System.Web.UI.WebControls.TextBox 1..TextBox = New System.Web.UI.WebControls.TextBox
0
1598
by: Lucas, Todd | last post by:
Hello everyone! I'm having a problem with a WebControl that I'm designing for a Menu. I've been at it for about 3 weeks now, and can't seem to get around this problem. So I'm hoping that someone can help me ... My environment: VS 2003 v7.1.3088, Win2K v5.0.2195 SP3, IE6 v6.0.2800.1106 browser. I have a class (C3Menu) derived from WebControl, with a property (MenuItems) that is a collection of menu items. The collection property is...
0
1818
by: Novice | last post by:
Hey all, I've already posted this question and two posters offered suggestions and they worked - but now I would like to know why - and if possible the answer to a second question. Here is my problem: I am trying to write a custom WebControl - at some point this WebControl will output a bunch of controls into several Panel objects. But I just recently got my WebControl to output a single button and attach an event handler to that...
0
1150
by: Alex Nitulescu | last post by:
Hi, I have the following in project "RaducuCustomControls": Imports System.ComponentModel Imports System.Web.UI <DefaultProperty("Text"), ToolboxData("<{0}:Rotator1 runat=server></{0}:Rotator1>")> Public Class Rotator1 Inherits System.Web.UI.WebControls.WebControl Public Items As New ArrayList()
0
1643
by: Mike Hofer | last post by:
Hi everyone. I could really use some help. First, the backstory: ===================== I *really* need a 3-state checkbox for my ASP.NET application. Specifically, I need one that lets me set the image for the checkbox portion so that the control conforms to my site's visual style, and that lets me set the style for the text in both the enabled and disabled states. As you might expect, I couldn't find one. So I decided to roll my own.
7
3422
by: n33470 | last post by:
We're in the process of migrating our projects to use VS2005 from VS2003. We have a web page that uses the XML WebControl (System.Web.UI.WebControls.Xml) to perform an XSLT tranformation by using the property "Transform" of the webcontrol. Here is a sample: xmlMessage.Transform = _app.Cache.UserMessagesXsltUser; 'xmlMessage' is the XML Web Control, and '_app.Cache.UserMessagesXsltUser' is the transformation to apply.
0
1257
by: Charlie | last post by:
When a property of a WebControl is changed at design-time in the property window, the Render method for that WebControls runs. When the property of one WebControl cascades to another WebControl, the actual property for the receiving control is changed, but the Render method for that control is not called. Manually calling Render causes an invalid property error. If I set the property in the properties window for the second control,...
0
2957
by: Demetri | last post by:
I have created a web control that can be rendered as either a linkbutton or a button. It is a ConfirmButton control that allows a developer to force a user to confirm if they intended to click it such as when they do a delete. Everything is great. By and large it will be used in my repeater controls using the command event when the user clicks on it and so that event is working great. My issue is the Click event. When the control is...
0
9646
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9484
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10350
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10097
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7505
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5386
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5518
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.