Hello,
I am creating a custom web control where one of its properties is a
generic list:
<Bindable(True) , Category("Forma t"), DefaultValue("" ),
Localizable(Tru e)Property Features() As Generic.List(Of Feature)
Get
If CStr(ViewState( "Features") ) Is Nothing Then
Return String.Empty
Else
Return CStr(ViewState( "Features") )
End If
End Get
Set(ByVal Value As String)
ViewState("Feat ures") = Value
End Set
End Property ' Features
This is the default way to create a property in a web control, as far
as I know.
I am getting an error saying that string cannot be converted to a
generic list.
How should I create my property?
Thanks,
Miguel 2 1179
Hi Miguel,
in the DefaultValue attribute you can assign a value to this property when
it is being created. It works in the same way as if you said:
Dim defaultValue as String
myInstance.Feat ures = defaultValue
This code would raise an exception, too.
You should either set the DefaultValue attribute to Nothing or assign some
proper value.
Are you experienced in developing server controls? I'm having trouble with
properties that should be influenced by Themes.
Do you think you could be of help there?
Best Regards,
Nico
Most likely this:
Get
If CStr(ViewState( "Features") ) Is Nothing Then
Return String.Empty
-- is what's causing it. You've defined the property type as List<Feature>
but your get accessor wants to return String.Empty, which obviously
is a different type than List<Feature>, make sense?
HTH,
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"shapper" wrote:
Hello,
I am creating a custom web control where one of its properties is a
generic list:
<Bindable(True) , Category("Forma t"), DefaultValue("" ),
Localizable(Tru e)Property Features() As Generic.List(Of Feature)
Get
If CStr(ViewState( "Features") ) Is Nothing Then
Return String.Empty
Else
Return CStr(ViewState( "Features") )
End If
End Get
Set(ByVal Value As String)
ViewState("Feat ures") = Value
End Set
End Property ' Features
This is the default way to create a property in a web control, as far
as I know.
I am getting an error saying that string cannot be converted to a
generic list.
How should I create my property?
Thanks,
Miguel
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Christian H |
last post by:
Hi!
I've created a custom control (myDrawControl) that deals with drawing.
This control is then added to a form( myMainForm)
Now, whenever something is dragged and dropped onto myDrawControl , I want
to update a variable in myMainForm that keeps track of the objects that have
been added.(ArrayList objectsAdded)
Now I'm a little confused... How can I do this, when the method that deals
|
by: Joe Bloggs |
last post by:
Does anyone know if its possible to pass parameters or the values of
Request.QueryString from a web page to a custom control class? I'm using
a C# Web Application. For Example I have Web Page1 which has to
parameters passed to it from another Web page
Parameter # 1 dbid and Parameter # 2 reportid.
I know that I can access the values of the parameters from the code
behind .aspx.cs using Request.QueryString so
|
by: Tinus |
last post by:
Hello all,
I've create a custom control (UserControl) and have a custom Item
Collection. The control is a custom calendar which is draw using the
Graphics Rectangle etc. functions. It is drawn when the control is painted
or resized. When the control is drawn it draws also the items found in the
collection.
So far so good.... I have 3 questions which I'm unable to find a solution
|
by: Jay Walker |
last post by:
I created a custom DataGridColumn based on Marcie Robillard's MSDN
Article:
Creating Custom Columns for the ASP.NET Datagrid
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/creatingcustomcolumns.asp
The problem I am having is that the data in the custom datagridcolumn
is not saved to viewstate and after postback, the column does not
contain data.
|
by: One Handed Man \( OHM - Terry Burns \) |
last post by:
When using a custom control. In order to check and see if values have
changed one has to implement the IPostBackDataCollection interface. The
values returned for the control seem to be simply a string with comma
delimited values.
For example, if I were to render two text boxes. One with the Value Terry
and the Other with the Value 'Burns' I would get the following value
Terry,Burns.
| |
by: Shimon Sim |
last post by:
I have a custom composite control
I have following property
|
by: Sanjay Pais |
last post by:
I built a custom control for all the basic web.ui.controls like textbox,
label, checkbox etc etc. I added my custom attribute called ApplySecurity to
the html in the page.
However, when I cycle through the controls on the page using this code, I
cant seem to be able to access the Attribute collection. However, if I were
to add the tag to a regular TextBox, the Attribute is available.
My recursive function looks like this:...
|
by: rn5a |
last post by:
I want to create a custom control that encapsulates a Button & a
TextBox. When the Button is clicked, the user is asked a question using
JavaScript confirm (which shows 2 buttons - 'OK' & 'Cancel'). Till this
point, no problem. Initially, the TextBox is empty. The Button has a
property named 'ConfirmMessage' so that the developer using this custom
control can modify the question in the confirm dialog.
If the user clicks 'OK', I want the...
|
by: Michal Valent |
last post by:
I would like to fire some custom server control event before Page_Load event
like this (from the trace of an aspx page) :
Trace Information
Category Message From First(s) From Last(s)
aspx.page Begin PreInit
aspx.page End PreInit 5,38454603734274E-05 0,000054
aspx.page Begin Init 8,96405962016187E-05 0,000036
aspx.page End Init 0,00072941040948794 0,000640
aspx.page Begin InitComplete 0,000772971258380746 0,000044
|
by: =?Utf-8?B?UmljaEI=?= |
last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I
would like to dynamically add panes to the control with a form template added
when the pane is added. I have tried unsuccessfully in creating the whole
pane as a user control and have succeeded in adding the pane and then
dynamically adding the content which is a user control to the pane,
dynamically within the page.
However I would like to have a single pane...
|
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...
| |
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,...
|
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...
|
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,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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();...
| |
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: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |