Custom Controls with non-String Attributes

N

Nathan Sokalski

I want to add attributes to my custom controls that are not of type String.
I know how to convert from a String to the different types that I want, but
when the user assigns values to the attributes using properties (assigns the
values programmatically) I want them to be able to use the type I would be
converting the attribute to. For example, here are the two basic scenarios:

Assigning the value using attributes:

<mytags:linkmaker runat="server" id="linkmaker1"
url="http://www.nathansokalski.com/"></mytags:linkmaker>

Assigning the value programmatically:

linkmaker1.url=New Uri("http://www.nathansokalski.com/")

The problem is that if I make the property of type Uri I recieve a Parser
Error, and if I make it a String the user cannot programmatically assign a
Uri to it. What do I do? Thanks.
 
G

Guest

Don't expose the url property. Instead, expose an intermediate property
that returns type URI. When the property is set, set the url property of
the linkmaker object, when it's requested, convert the value of the
linkmaker url to a URI and return it.

HTH
 
N

Nathan Sokalski

I'm not sure what you mean by that. Is there a small code snippet or example
I could see? Thanks.
 
G

Guest

Hello, I'm creating a custom web control and i need to set some properties
for it.
I would like to have some properties with integer values validation, colors
palette and a drop down list with some established options.
So far i've declared some reference values like integer and its
setIntegerValue functions. Also i declared a System.Draw.Color color_var_name
variable and defined a "set color" function to receive the values in the
properties menu after clicking the web control.
The "setColor" properties displays a dropdown list with values as cyan,
black and so on. I would like to know if its possible to use a palette with
color picker instead and also to declare some validation for the entered
integer values or a predefinded range.
Another question is if there is a method to have embebbed javascript and css
files with the web control. I know there is one with the server control.
I'm quite new to .net and I would appreciate any help.
Thanks a lot in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top