Home All Groups Group Topic Archive Search About

Custom Controls with non-String Attributes

Author
24 Jun 2006 9:23 PM
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.
--
Nathan Sokalski
njsokal***@hotmail.com
http://www.nathansokalski.com/

Author
26 Jun 2006 12:46 AM
Tim Dot NoSpam
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

Show quoteHide quote
"Nathan Sokalski" <njsokal***@hotmail.com> wrote in message
news:uTs6yR9lGHA.4076@TK2MSFTNGP03.phx.gbl...
>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.
> --
> Nathan Sokalski
> njsokal***@hotmail.com
> http://www.nathansokalski.com/
>
Author
26 Jun 2006 3:54 AM
Nathan Sokalski
I'm not sure what you mean by that. Is there a small code snippet or example
I could see? Thanks.
--
Nathan Sokalski
njsokal***@hotmail.com
http://www.nathansokalski.com/

Show quoteHide quote
"Tim Dot NoSpam" <Tim@MindYourSpammy.spam> wrote in message
news:uUoQgoLmGHA.4100@TK2MSFTNGP05.phx.gbl...
> 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
>
> "Nathan Sokalski" <njsokal***@hotmail.com> wrote in message
> news:uTs6yR9lGHA.4076@TK2MSFTNGP03.phx.gbl...
>>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.
>> --
>> Nathan Sokalski
>> njsokal***@hotmail.com
>> http://www.nathansokalski.com/
>>
>
>
Author
28 Jun 2006 9:20 AM
Marco Antonio
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.