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

Extended control issue

Hello,

I got a problem when I try to extend a textbox.
So I overwrite the Render method. For the stuff I try to do, I would like
to add a custom attribute to my customized textbox.
So it renders something like this:
<input ... myattribute="value" />

I modify the value of "myattribute" using javascript, but when I submit my
form, I can't get the value of "myattribute".

Do I have to create create a class extended the attribute class? How do I
have to proceed?

Thank you in advance,
Fabien.
Dec 25 '07 #1
12 1261

"Fabien Henriet" <fa************@nospam.bewrote in message
news:e%****************@TK2MSFTNGP04.phx.gbl...
Hello,

I got a problem when I try to extend a textbox.
So I overwrite the Render method. For the stuff I try to do, I would like
to add a custom attribute to my customized textbox.
So it renders something like this:
<input ... myattribute="value" />

I modify the value of "myattribute" using javascript, but when I submit my
form, I can't get the value of "myattribute".

Do I have to create create a class extended the attribute class? How do I
have to proceed?

Thank you in advance,
Fabien.
When you submit the form, each form element with a "name" attribute and a
"value" attribute will be sent as a 'pair' or 'set' of name=value pairs. For
example <input type="hidden" name="color" value="blue" / this element will
provide color=blue.
HTH
Dec 26 '07 #2
Thank you for your quick answer!
I've already thought to use an hiddenfield. But I don't know how to get the
value of this field in my extended control.

I explain: when I submit my form, I call a method of my extended textbox and
within this method, I would like to test the value of my hiddenfield. I
prefer not to make that test in code behind of my page.

Thanks in advance for your help.

Fabien.
"Hal Rosser" <hm******@bellsouth.neta écrit dans le message de news:
fj*******************@bignews8.bellsouth.net...
>
"Fabien Henriet" <fa************@nospam.bewrote in message
news:e%****************@TK2MSFTNGP04.phx.gbl...
>Hello,

I got a problem when I try to extend a textbox.
So I overwrite the Render method. For the stuff I try to do, I would
like to add a custom attribute to my customized textbox.
So it renders something like this:
<input ... myattribute="value" />

I modify the value of "myattribute" using javascript, but when I submit
my form, I can't get the value of "myattribute".

Do I have to create create a class extended the attribute class? How do
I have to proceed?

Thank you in advance,
Fabien.

When you submit the form, each form element with a "name" attribute and a
"value" attribute will be sent as a 'pair' or 'set' of name=value pairs.
For example <input type="hidden" name="color" value="blue" / this
element will provide color=blue.
HTH

Dec 26 '07 #3
Hi,

it's simple, find the HiddenField in page (you can get the current page
instance by anyControl.Page), every control has a FindControl method (but it
searches only his childs not childs of his childs.....) so if the
hiddenField is somewhere deep, you will have use recursion to find the
control. Then you will get it's value by yourHiddenField.Value

Regards,

Lukas Holota

"Fabien Henriet" <fa************@nospam.bewrote in message
news:eR**************@TK2MSFTNGP03.phx.gbl...
Thank you for your quick answer!
I've already thought to use an hiddenfield. But I don't know how to get
the value of this field in my extended control.

I explain: when I submit my form, I call a method of my extended textbox
and within this method, I would like to test the value of my hiddenfield.
I prefer not to make that test in code behind of my page.

Thanks in advance for your help.

Fabien.
"Hal Rosser" <hm******@bellsouth.neta écrit dans le message de news:
fj*******************@bignews8.bellsouth.net...
>>
"Fabien Henriet" <fa************@nospam.bewrote in message
news:e%****************@TK2MSFTNGP04.phx.gbl...
>>Hello,

I got a problem when I try to extend a textbox.
So I overwrite the Render method. For the stuff I try to do, I would
like to add a custom attribute to my customized textbox.
So it renders something like this:
<input ... myattribute="value" />

I modify the value of "myattribute" using javascript, but when I submit
my form, I can't get the value of "myattribute".

Do I have to create create a class extended the attribute class? How do
I have to proceed?

Thank you in advance,
Fabien.

When you submit the form, each form element with a "name" attribute and a
"value" attribute will be sent as a 'pair' or 'set' of name=value pairs.
For example <input type="hidden" name="color" value="blue" / this
element will provide color=blue.
HTH

Dec 26 '07 #4
Hello,

Thank you but it doesn't work. I try in debug mode. In fact, I can find
the value of my hiddenfield by using
(this.Page.Request.Form.GetValues(base.ID + "_hidden"))[0], but the value is
not the good one. The value is the orignal one (before any modification in
javascript). I can't get the value modified by the javascript.
I cannot use FindControl because at this time, the object is not yet
"re-created" (after submit but before render).

Regards and thank you again,
Fabien.
<l.******@hotmail.coma écrit dans le message de news:
86**********************************@microsoft.com...
Hi,

it's simple, find the HiddenField in page (you can get the current page
instance by anyControl.Page), every control has a FindControl method (but
it searches only his childs not childs of his childs.....) so if the
hiddenField is somewhere deep, you will have use recursion to find the
control. Then you will get it's value by yourHiddenField.Value

Regards,

Lukas Holota

"Fabien Henriet" <fa************@nospam.bewrote in message
news:eR**************@TK2MSFTNGP03.phx.gbl...
>Thank you for your quick answer!
I've already thought to use an hiddenfield. But I don't know how to get
the value of this field in my extended control.

I explain: when I submit my form, I call a method of my extended textbox
and within this method, I would like to test the value of my hiddenfield.
I prefer not to make that test in code behind of my page.

Thanks in advance for your help.

Fabien.
"Hal Rosser" <hm******@bellsouth.neta écrit dans le message de news:
fj*******************@bignews8.bellsouth.net...
>>>
"Fabien Henriet" <fa************@nospam.bewrote in message
news:e%****************@TK2MSFTNGP04.phx.gbl.. .
Hello,

I got a problem when I try to extend a textbox.
So I overwrite the Render method. For the stuff I try to do, I would
like to add a custom attribute to my customized textbox.
So it renders something like this:
<input ... myattribute="value" />

I modify the value of "myattribute" using javascript, but when I submit
my form, I can't get the value of "myattribute".

Do I have to create create a class extended the attribute class? How
do I have to proceed?

Thank you in advance,
Fabien.

When you submit the form, each form element with a "name" attribute and
a "value" attribute will be sent as a 'pair' or 'set' of name=value
pairs. For example <input type="hidden" name="color" value="blue" />
this element will provide color=blue.
HTH


Dec 26 '07 #5
Hi, Fabien,

You're almost there with the solution, but instead of using base.ID
use this.ClientID.

This way you'll make sure that the property is retrieved no matter
where the control is placed.

It's always dificult to create custom properties on the client side...

One of the most terrifying aspects of it is the lack of
__defineGetter__ and __defineSetter__ in the Internet Explorer, which
I circunvent using behaviors (and __defineGetter__ and
__defineSetter__ for Gecko) it's ugly but it works.

So if you want your property to mork like, say, "value" you'll need to
type some more code. ;)

Let me know if you have questions

Paulo Santos
http://pjondevelopment.50webs.com

On Dec 26, 8:59*am, "Fabien Henriet" <fabien.henr...@nospam.bewrote:
Hello,

Thank you but it doesn't work. *I try in debug mode. *In fact, I can find
the value of my hiddenfield by using
(this.Page.Request.Form.GetValues(base.ID + "_hidden"))[0], but the value is
not the good one. *The value is the orignal one (before any modificationin
javascript). *I can't get the value modified by the javascript.
I cannot use FindControl because at this time, the object is not yet
"re-created" (after submit but before render).

Regards and thank you again,
Fabien.

<l.hol...@hotmail.coma écrit dans le message de news:
86EB63DB-35C8-494E-BD4B-BD10203F1...@microsoft.com...
Hi,
* *it's simple, find the HiddenField in page (you can get the current page
instance by anyControl.Page), every control has a FindControl method (but
it searches only his childs not childs of his childs.....) so if the
hiddenField is somewhere deep, you will have use recursion to find the
control. Then you will get it's value by yourHiddenField.Value
Regards,
Lukas Holota
"Fabien Henriet" <fabien.henr...@nospam.bewrote in message
news:eR**************@TK2MSFTNGP03.phx.gbl...
Thank you for your quick answer!
I've already thought to use an hiddenfield. *But I don't know how to get
the value of this field in my extended control.
I explain: when I submit my form, I call a method of my extended textbox
and within this method, I would like to test the value of my hiddenfield.
I prefer not to make that test in code behind of my page.
Thanks in advance for your help.
Fabien.
"Hal Rosser" <hmros...@bellsouth.neta écrit dans le message de news:
fjhcj.30637$vt2.27...@bignews8.bellsouth.net...
>"Fabien Henriet" <fabien.henr...@nospam.bewrote in message
news:e%****************@TK2MSFTNGP04.phx.gbl.. .
Hello,
>>I got a problem when I try to extend a textbox.
So I overwrite the Render method. *For the stuff I try to do, I would
like to add a custom attribute to my customized textbox.
So it renders something like this:
<input ... myattribute="value" />
>>I modify the value of "myattribute" using javascript, but when I submit
my form, I can't get the value of "myattribute".
>>Do I have to create create a class extended the attribute class? *How
do I have to proceed?
>>Thank you in advance,
Fabien.
>When you submit the form, each form element with a "name" attribute and
a "value" attribute will be sent as a 'pair' or 'set' of name=value
pairs. For example <input type="hidden" name="color" value="blue" />
this element will provide color=blue.
HTH- Hide quoted text -

- Show quoted text -
Dec 26 '07 #6
Hello,

Thank you for your answer, but I'm not sure to understand the difference
between base.Id and this.ClientID... Both of those strings will return the
same value... I can get back the id or name of my hiddenfield, I can't get
back the value of this item assigned client-side.

Am I wrong?

Regards,
Fabien.
"PJ on Development" <pj*************@gmail.coma écrit dans le message de
news: 1b**********************************...oglegroups.com...
Hi, Fabien,

You're almost there with the solution, but instead of using base.ID
use this.ClientID.

This way you'll make sure that the property is retrieved no matter
where the control is placed.

It's always dificult to create custom properties on the client side...

One of the most terrifying aspects of it is the lack of
__defineGetter__ and __defineSetter__ in the Internet Explorer, which
I circunvent using behaviors (and __defineGetter__ and
__defineSetter__ for Gecko) it's ugly but it works.

So if you want your property to mork like, say, "value" you'll need to
type some more code. ;)

Let me know if you have questions

Paulo Santos
http://pjondevelopment.50webs.com

On Dec 26, 8:59 am, "Fabien Henriet" <fabien.henr...@nospam.bewrote:
Hello,

Thank you but it doesn't work. I try in debug mode. In fact, I can find
the value of my hiddenfield by using
(this.Page.Request.Form.GetValues(base.ID + "_hidden"))[0], but the value
is
not the good one. The value is the orignal one (before any modification in
javascript). I can't get the value modified by the javascript.
I cannot use FindControl because at this time, the object is not yet
"re-created" (after submit but before render).

Regards and thank you again,
Fabien.

<l.hol...@hotmail.coma écrit dans le message de news:
86EB63DB-35C8-494E-BD4B-BD10203F1...@microsoft.com...
Hi,
it's simple, find the HiddenField in page (you can get the current page
instance by anyControl.Page), every control has a FindControl method
(but
it searches only his childs not childs of his childs.....) so if the
hiddenField is somewhere deep, you will have use recursion to find the
control. Then you will get it's value by yourHiddenField.Value
Regards,
Lukas Holota
"Fabien Henriet" <fabien.henr...@nospam.bewrote in message
news:eR**************@TK2MSFTNGP03.phx.gbl...
Thank you for your quick answer!
I've already thought to use an hiddenfield. But I don't know how to get
the value of this field in my extended control.
I explain: when I submit my form, I call a method of my extended
textbox
and within this method, I would like to test the value of my
hiddenfield.
I prefer not to make that test in code behind of my page.
Thanks in advance for your help.
Fabien.
"Hal Rosser" <hmros...@bellsouth.neta écrit dans le message de news:
fjhcj.30637$vt2.27...@bignews8.bellsouth.net...
>"Fabien Henriet" <fabien.henr...@nospam.bewrote in message
news:e%****************@TK2MSFTNGP04.phx.gbl.. .
Hello,
>>I got a problem when I try to extend a textbox.
So I overwrite the Render method. For the stuff I try to do, I would
like to add a custom attribute to my customized textbox.
So it renders something like this:
<input ... myattribute="value" />
>>I modify the value of "myattribute" using javascript, but when I
submit
my form, I can't get the value of "myattribute".
>>Do I have to create create a class extended the attribute class? How
do I have to proceed?
>>Thank you in advance,
Fabien.
>When you submit the form, each form element with a "name" attribute
and
a "value" attribute will be sent as a 'pair' or 'set' of name=value
pairs. For example <input type="hidden" name="color" value="blue" />
this element will provide color=blue.
HTH- Hide quoted text -

- Show quoted text -

Dec 27 '07 #7
"Fabien Henriet" <fa************@nospam.bewrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Thank you for your answer, but I'm not sure to understand the difference
between base.Id and this.ClientID... Both of those strings will return
the same value... I can get back the id or name of my hiddenfield, I
can't get back the value of this item assigned client-side.
Does this thread help?
http://forums.asp.net/p/1039574/1444169.aspx
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Dec 27 '07 #8
Hi Mark,

Yes and No. I explain. I render the hiddenfield this way:
HiddenField hiddenField = new HiddenField();

hiddenField.ID = base.ID + "_hidden";

hiddenField.EnableViewState = true;

hiddenField.Value = false.ToString();

hiddenField.RenderControl(writer);

This is in my "protected override void Render(System.Web.UI.HtmlTextWriter
writer)" method of my extended textbox. How to specify "runat=server"?

During postback my value is the one I set in hiddenField.Value, not the one
javascript set.

Any idea?

Thank in advance,
Fabien.
"Mark Rae [MVP]" <ma**@markNOSPAMrae.neta écrit dans le message de news:
uY**************@TK2MSFTNGP03.phx.gbl...
"Fabien Henriet" <fa************@nospam.bewrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>Thank you for your answer, but I'm not sure to understand the difference
between base.Id and this.ClientID... Both of those strings will return
the same value... I can get back the id or name of my hiddenfield, I
can't get back the value of this item assigned client-side.

Does this thread help?
http://forums.asp.net/p/1039574/1444169.aspx
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Dec 27 '07 #9
"Fabien Henriet" <fa************@nospam.bewrote in message
news:uy**************@TK2MSFTNGP05.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

Dec 27 '07 #10
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]" <ma**@markNOSPAMrae.neta écrit dans le message de news:
eg**************@TK2MSFTNGP04.phx.gbl...
"Fabien Henriet" <fa************@nospam.bewrote in message
news:uy**************@TK2MSFTNGP05.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

Dec 27 '07 #11
"Fabien Henriet" <fa************@nospam.bewrote in message
news:eK**************@TK2MSFTNGP06.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

Dec 27 '07 #12
Thank you for your kind help, I'll do that.

Regards,
Fabien.

"Mark Rae [MVP]" <ma**@markNOSPAMrae.neta écrit dans le message de news:
Or**************@TK2MSFTNGP03.phx.gbl...
"Fabien Henriet" <fa************@nospam.bewrote in message
news:eK**************@TK2MSFTNGP06.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

Dec 27 '07 #13

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

Similar topics

2
by: Christian Wilcox | last post by:
I'm trying to programmatically access information from a telnet session which is normally accessed with a telnet program capable of terminal emulation (currently set at VT320). The initial login...
12
by: Jeremy | last post by:
Hi all, I'm getting very confused about how DB2 uses shared memory and I wonder if someone could clarify matters for me, please ? We are running 32bit DB2 V7.2 FP9 under AIX 4.3.3 on a machine...
4
by: wob | last post by:
Many thanks for those who responded to my question of "putting greek char into C string". In searching for an solution, I noticed that there are more than one version of "Extended ASCII...
3
by: ppateel | last post by:
Hi, First I would like to apologize for cross posting in three groups as I did not know which one would be the appropriate group. If some one points me to the correct one I will use that in the...
1
by: Jibber | last post by:
Sorry for the similar post, but I have clarified the problem a bit more. The issue is: how do I use an extended .NET control in a webform using VS2005. In my case, I am overriding the Render for a...
10
by: KarlM | last post by:
Hallo! Due to the help in this Newgroups I am now able to set basic rights to a Computer account in active directory. The following c#-Code works fine...
4
by: =?Utf-8?B?TWF0dCBMb3Zl?= | last post by:
If I extend the WebBrowser class like this: public class CustomWebBrowser : System.Windows.Forms.WebBrowser { public string myProperty() { return "myProperty"; } }
13
by: ramif | last post by:
Is there a way to print extended ASCII in C?? I tried to code something, but it only displays strange symbols. here is my code: main() { char chr = 177; //stores the extended ASCII...
6
by: SAL | last post by:
hello, I'm using a radiobuttonlist in an updatepanel in an item template in a Gridview control. I'm populating the radiobuttonlist in the RowDataBound event. I have the control toolkit registered...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.