HighTechTalks DotNet Forums  

Extended control issue

ASP.net ASP.net discussions (microsoft.public.dotnet.framework.aspnet)


Discuss Extended control issue in the ASP.net forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #11  
Old   
Fabien Henriet
 
Posts: n/a

Default Re: Extended control issue - 12-27-2007 , 04:49 AM






Hello Mark,

I try to create our own custom controls and I would like to make it the most
generic you can have. We create a lot of controls to use in web pages.
It's a kind of central project used in all our websites.
Anyway, we thought a lot over that and the best way for us was to extend
TextBox class and so on... So we took this way.

I can't imagine you cannot add some attributes to an object. If I modify
Text attribute, I can get its value, why can't I do that with another
property? I heard about custom attributes. I defined my own attribute and
try to use it in my class. I can change the value within javascript. But
do you know how to get the value server-side?

Can you give me a good tutorial with custom attributes and confirm me I can
use them to solve my problem?

Thank you in advance,
Fabien.

"Mark Rae [MVP]" <mark (AT) markNOSPAMrae (DOT) net> a écrit dans le message de news:
egaqjqGSIHA.1188 (AT) TK2MSFTNGP04 (DOT) phx.gbl...
Quote:
"Fabien Henriet" <fabien.henriet (AT) nospam (DOT) be> wrote in message
news:uycCgTGSIHA.5128 (AT) TK2MSFTNGP05 (DOT) phx.gbl...

I render the hiddenfield this way:

Why? Have you tried simply to add the hidden field to your UserControl's
markup just like any other control...?


--
Mark Rae
ASP.NET MVP
http://www.markrae.net



Reply With Quote
  #12  
Old   
Mark Rae [MVP]
 
Posts: n/a

Default Re: Extended control issue - 12-27-2007 , 06:49 AM






"Fabien Henriet" <fabien.henriet (AT) nospam (DOT) be> wrote


Quote:
Anyway, we thought a lot over that and the best way for us was to extend
TextBox class and so on...
Why?

Quote:
I can't imagine you cannot add some attributes to an object.
You can...

Quote:
If I modify Text attribute, I can get its value, why can't I do that with
another property?
The Text attribute already exists for the TextBox control. I think the
problem is that you are modifying the TextBox control far too late in the
page lifecycle. Generally speaking, custom controls need to be created no
later than Page_Init...

Quote:
Can you give me a good tutorial with custom attributes and confirm me I
can use them to solve my problem?
Create a UserControl which contains a TextBox and a HiddenField, and your
problems will disappear...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net



Reply With Quote
  #13  
Old   
Fabien Henriet
 
Posts: n/a

Default Re: Extended control issue - 12-27-2007 , 07:08 AM



Thank you for your kind help, I'll do that.

Regards,
Fabien.

"Mark Rae [MVP]" <mark (AT) markNOSPAMrae (DOT) net> a écrit dans le message de news:
OrCf25HSIHA.6036 (AT) TK2MSFTNGP03 (DOT) phx.gbl...
Quote:
"Fabien Henriet" <fabien.henriet (AT) nospam (DOT) be> wrote in message
news:eKXrZ3GSIHA.4684 (AT) TK2MSFTNGP06 (DOT) phx.gbl...

Anyway, we thought a lot over that and the best way for us was to extend
TextBox class and so on...

Why?

I can't imagine you cannot add some attributes to an object.

You can...

If I modify Text attribute, I can get its value, why can't I do that with
another property?

The Text attribute already exists for the TextBox control. I think the
problem is that you are modifying the TextBox control far too late in the
page lifecycle. Generally speaking, custom controls need to be created no
later than Page_Init...

Can you give me a good tutorial with custom attributes and confirm me I
can use them to solve my problem?

Create a UserControl which contains a TextBox and a HiddenField, and your
problems will disappear...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.