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

Custom web control string

Hello,

I am creating a custom web control where one of its properties is a
generic list:

<Bindable(True), Category("Format"), DefaultValue(""),
Localizable(True)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("Features") = 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

May 10 '07 #1
2 1163
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.Features = 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
May 10 '07 #2
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("Format"), DefaultValue(""),
Localizable(True)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("Features") = 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

May 10 '07 #3

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

Similar topics

6
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 ,...
3
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...
8
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...
2
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...
21
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...
7
by: Shimon Sim | last post by:
I have a custom composite control I have following property
1
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...
1
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' &...
2
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...
4
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
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,...
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...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.