473,387 Members | 1,899 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,387 software developers and data experts.

'True' could not be set on property

PJ6
I get this design-time error (below) when setting thus property in my
inherited web control to 'True'. I've debugged the code running at
design-time to double check to see that no exception was being thrown. While
there are other people that have run into this exception, what I've found so
far hasn't been helpful.

What is the proper way to declare custom Boolean properties that need to be
persisted in attributes through the Web Forms designer?

Paul

There was an error rendering the control.
'True' could not be set on property 'ShowEmptySelection'.

<DefaultValue(False), _
DesignerSerializationVisibility(DesignerSerializat ionVisibility.Visible),
_
PersistenceMode(PersistenceMode.Attribute), _
Bindable(True), Category("Appearance")_
Public Overridable Property ShowEmptySelection() As Boolean
Get
Dim ret As Boolean = False
Dim o As Object = Me.ViewState("ShowEmptySelection")
If Not o Is Nothing Then
ret = CBool(o)
End If
Return ret
End Get
Set(ByVal value As Boolean)
Me.ViewState("ShowEmptySelection") = value
End Set
End Property
Oct 8 '07 #1
4 2609

"PJ6" <no***@nowhere.netwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>I get this design-time error (below) when setting thus property in my
inherited web control to 'True'. I've debugged the code running at
design-time to double check to see that no exception was being thrown.
While there are other people that have run into this exception, what I've
found so far hasn't been helpful.

What is the proper way to declare custom Boolean properties that need to
be persisted in attributes through the Web Forms designer?

Paul

There was an error rendering the control.
'True' could not be set on property 'ShowEmptySelection'.

<DefaultValue(False), _

DesignerSerializationVisibility(DesignerSerializat ionVisibility.Visible),
_
PersistenceMode(PersistenceMode.Attribute), _
Bindable(True), Category("Appearance")_
Public Overridable Property ShowEmptySelection() As Boolean
Get
Dim ret As Boolean = False
Dim o As Object = Me.ViewState("ShowEmptySelection")
If Not o Is Nothing Then
ret = CBool(o)
End If
Return ret
End Get
Set(ByVal value As Boolean)
Me.ViewState("ShowEmptySelection") = value
End Set
End Property

I'm not sure, but if you don't mind, may I suggest you change your Get code?
What you have there is very unneccessary.

Public Overridable Property ShowEmptySelection() As Boolean
Get
If Me.ViewState("ShowEmptySelection") IsNot Nothing Then Return
True
Return False
End Get
Set(ByVal value As Boolean)
Me.ViewState("ShowEmptySelection") = value
End Set
End Property

Oct 9 '07 #2
Scott M. wrote:
>
"PJ6" <no***@nowhere.netwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>I get this design-time error (below) when setting thus property in my
inherited web control to 'True'. I've debugged the code running at
design-time to double check to see that no exception was being thrown.
While there are other people that have run into this exception, what
I've found so far hasn't been helpful.

What is the proper way to declare custom Boolean properties that need
to be persisted in attributes through the Web Forms designer?

Paul

There was an error rendering the control.
'True' could not be set on property 'ShowEmptySelection'.

<DefaultValue(False), _

DesignerSerializationVisibility(DesignerSerializa tionVisibility.Visible),
_
PersistenceMode(PersistenceMode.Attribute), _
Bindable(True), Category("Appearance")_
Public Overridable Property ShowEmptySelection() As Boolean
Get
Dim ret As Boolean = False
Dim o As Object = Me.ViewState("ShowEmptySelection")
If Not o Is Nothing Then
ret = CBool(o)
End If
Return ret
End Get
Set(ByVal value As Boolean)
Me.ViewState("ShowEmptySelection") = value
End Set
End Property


I'm not sure, but if you don't mind, may I suggest you change your Get
code? What you have there is very unneccessary.

Public Overridable Property ShowEmptySelection() As Boolean
Get
If Me.ViewState("ShowEmptySelection") IsNot Nothing Then
Return True
Return False
End Get
Set(ByVal value As Boolean)
Me.ViewState("ShowEmptySelection") = value
End Set
End Property
But that will make the property always return true if there is a value
in view state, regardless of the actual value.

--
Göran Andersson
_____
http://www.guffa.com
Oct 9 '07 #3
"Göran Andersson" <gu***@guffa.comwrote in message
news:uq**************@TK2MSFTNGP03.phx.gbl...
But that will make the property always return true if there is a value in
view state, regardless of the actual value.
It seems like that's what the OP wants here since all he was doing in his
original code was casting the value to a Boolean. Wouldn't any value cause
the cast to result in True, but no value would cause False?
Oct 9 '07 #4
To follow up...

If the OP wanted the "value" of the ViewState item cast as a boolean, should
he not have casted the ViewState item to a string and cast that, rather than
cast the ViewState "item" to an object?

"Scott M." <s-***@nospam.nospamwrote in message
news:O7**************@TK2MSFTNGP06.phx.gbl...
"Göran Andersson" <gu***@guffa.comwrote in message
news:uq**************@TK2MSFTNGP03.phx.gbl...
>But that will make the property always return true if there is a value in
view state, regardless of the actual value.

It seems like that's what the OP wants here since all he was doing in his
original code was casting the value to a Boolean. Wouldn't any value
cause the cast to result in True, but no value would cause False?

Oct 9 '07 #5

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

Similar topics

15
by: F. Da Costa | last post by:
Hi all, Following two sniperts of code I'm using and getting very interesting results from. ..html <tr id="1" class="segment" open="false"> This is the segment under 'investigation' ..js
2
by: vakap | last post by:
function show() { var s = '' ; for (var i = 0; i<arguments.length; s += '\n'+arguments) ; typeof(window) != 'undefined' ? window.alert(s) : WScript.Echo(s) ; } function f(){}...
3
by: rosty | last post by:
This is taken from MSDN (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html /frlrfsystemwindowsformstextboxclasspasswordchartopic.asp) "When the PasswordChar property is...
8
by: Matthew Louden | last post by:
why need to set autopostback property to be true?? I know autopostback event means to send the form to the server automatically. I tried checkbox, checkbox list, radio button, and radio button...
1
by: Edward | last post by:
I am having a terrible time getting anything useful out of a listbox on my web form. I am populating it with the results from Postcode lookup software, and it is showing the results fine. What...
2
by: Guy Lafleur | last post by:
I have a user control that builds a treeview dynamically in the Page_Load event. Also, I have the AutoEventWireup property set to true (i.e., <%@ Control AutoEventWireup="true" %>). Then, when I...
0
by: Alli | last post by:
I have a web user control with a property that has the browsable attribute set to true, but property doesn't show up in the HTML design property window when I add the control to a web form. My...
1
by: Nicholas Palmer | last post by:
Hi all, Got a question about the AspCompat=true page property. First a little background. We have an ASP.NET app that uses two COM components. The first is the Microsoft OWC 11 components and...
4
by: Weston | last post by:
I've been playing around with some means of testing image loading, and noticing that the "complete" property seems to default to true. Trying the following in the squarefree javascript shell: I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.