Hi group,
the aspx statement :
<asp:TextBox ID="testTB" runat="server" Text="My test" />
generate html :
<input name="testTB" type="text" value="My test" id="testTB" />
Imagine I want to create a custom web control, extending the TextBox
control to add a custom hidden value.
Something like :
<MyNamespace:MyTextBox ID="testTB" runat="server" Text="My test"
HiddenValue="a value" />
that can generate such html code :
<input name="testTB" type="text" value="My test" id="testTB" />
<input name="hid_testTB" type="hidden" value="a value"
id="hid_testTB" />
How can I render such html code ? (without having to rewritte all
using writer.WriteBeginTag , and other writer.WriteAttribute)
Something like
protected override void ?? (...)
{
RenderTheBaseControl();
RenderTheAddedHiddenField();
}
How can I do ?
Thanks in advance for your help.
S. 8 2205
I want my own custom control to be able to add both TextBox control
and HiddenField, not adding 2 control in my page.
This is an example, maybe later I would like to do something
different, but I would like to understand how I can override the
render by adding html code
On 18 déc, 11:53, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
<timor.su...@gmail.comwrote in message
news:aa**********************************@18g2000h sf.googlegroups.com...
How can I render such html code?
http://msdn2.microsoft.com/en-us/lib...01(VS.80).aspx
--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
<ti*********@gmail.comwrote in message
news:98**********************************@o42g2000 hsc.googlegroups.com...
On 18 déc, 11:53, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
<timor.su...@gmail.comwrote in message
news:aa**********************************@18g2000h sf.googlegroups.com...
>>How can I render such html code?
http://msdn2.microsoft.com/en-us/lib...01(VS.80).aspx
I want my own custom control to be able to add both TextBox control
and HiddenField, not adding 2 control in my page.
Apologies, but I don't understand what the problem is...
You can have as many controls as you like in your UserControl - see examples
here: http://www.15seconds.com/issue/020319.htm
If you want to create a UserControl which has a TextBox and a HiddenField,
then create a UserControl with a TextBox and a HiddenField - when you add it
to your page and set the various properties, it will render the HTML you
want...
--
Mark Rae
ASP.NET MVP http://www.markrae.net
Thanks for your answer, but I don't want to use UserControl because I
need some specific uses, such as RaiseCallbackEvent.
That's why I was thinking of a custom webcontrols, inheriting from
TextBox
And somewhere in a render method, render the TextBox and render the
HiddenField, but I don't know how
You see ?
On 18 déc, 12:26, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
<timor.su...@gmail.comwrote in message
news:98**********************************@o42g2000 hsc.googlegroups.com...
On 18 déc, 11:53, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
<timor.su...@gmail.comwrote in message
news:aa**********************************@18g2000h sf.googlegroups.com...
>How can I render such html code?
>http://msdn2.microsoft.com/en-us/lib...01(VS.80).aspx
I want my own custom control to be able to add both TextBox control
and HiddenField, not adding 2 control in my page.
Apologies, but I don't understand what the problem is...
You can have as many controls as you like in your UserControl - see examples
here:http://www.15seconds.com/issue/020319.htm
If you want to create a UserControl which has a TextBox and a HiddenField,
then create a UserControl with a TextBox and a HiddenField - when you add it
to your page and set the various properties, it will render the HTML you
want...
--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
Hello Timor
Iam not sure wether i understood or not ;-)
Its possible to do something like:
protected override Render(object sender, HtmlTextWriter writer) {
// Render the TextBox (Base Control)
base.Render(writer);
// Render the HiddenField
this.RenderMyHiddenField(writer);
}
protected void RenderMyHiddenField(HtmlTextWriter writer) {
// Render....
}
In your new methode, you can render the hiddenfield using the "writer"
object.
--
Gruss, Peter Bucher
Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerland http://www.aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET
<ti*********@gmail.comwrote in message
news:83**********************************@l32g2000 hse.googlegroups.com...
Thanks for your answer, but I don't want to use UserControl because I
need some specific uses, such as RaiseCallbackEvent.
That's why I was thinking of a custom webcontrols, inheriting from
TextBox
And somewhere in a render method, render the TextBox and render the
HiddenField, but I don't know how
You see ?
No, I'm afraid I don't... There's nothing preventing you from using
RaiseCallbackEvent in a UserControl - here's an example of how to do it with
a UserControl which contains two ListBox controls: http://www.c-sharpcorner.com/UploadF...BoxesFT_1.aspx
--
Mark Rae
ASP.NET MVP http://www.markrae.net
Thanks both for your help,
The Peter's solution helps me to understand that it's very simple to
play with writer.
Mark's solution help me reconsidering what I want.
I think I will find what I want
Thanks for your help.
Best regards,
On 18 déc, 14:07, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
<timor.su...@gmail.comwrote in message
news:83**********************************@l32g2000 hse.googlegroups.com...
Thanks for your answer, but I don't want to use UserControl because I
need some specific uses, such as RaiseCallbackEvent.
That's why I was thinking of a custom webcontrols, inheriting from
TextBox
And somewhere in a render method, render the TextBox and render the
HiddenField, but I don't know how
You see ?
No, I'm afraid I don't... There's nothing preventing you from using
RaiseCallbackEvent in a UserControl - here's an example of how to do it with
a UserControl which contains two ListBox controls:http://www.c-sharpcorner..com/Upload..._ListBoxesFT_1...
--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
It isn't really clear from your post what the goal is, but it's very easy to
add attributes to any ASP.NET control:
this:
protected void Page_Load(object sender, EventArgs e)
{
this.TextBox1.Attributes.Add("hiddenField", "blahblah");
}
would render like this:
<input name="TextBox1" type="text" id="TextBox1" hiddenField="blahblah" />
--Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"ti*********@gmail.com" wrote:
Hi group,
the aspx statement :
<asp:TextBox ID="testTB" runat="server" Text="My test" />
generate html :
<input name="testTB" type="text" value="My test" id="testTB" />
Imagine I want to create a custom web control, extending the TextBox
control to add a custom hidden value.
Something like :
<MyNamespace:MyTextBox ID="testTB" runat="server" Text="My test"
HiddenValue="a value" />
that can generate such html code :
<input name="testTB" type="text" value="My test" id="testTB" />
<input name="hid_testTB" type="hidden" value="a value"
id="hid_testTB" />
How can I render such html code ? (without having to rewritte all
using writer.WriteBeginTag , and other writer.WriteAttribute)
Something like
protected override void ?? (...)
{
RenderTheBaseControl();
RenderTheAddedHiddenField();
}
How can I do ?
Thanks in advance for your help.
S. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Eric Anderson |
last post by:
I am trying to use XSLT to extend XHTML so that I can have custom
widgets. For example I have a calendar control. Whenever I put the
following in the psudo-XHTML doc:
<calendarbox name="mycal"/>...
|
by: __PPS__ |
last post by:
Hello, I'm newbe to xml/dtd (and probably I don't use all the termins
correctly). I'm writing an application that parses xhtml file with
custom elements and splits it into 2 parts - valid xhtml1.0...
|
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...
|
by: Dales |
last post by:
I have a custom control that builds what we refer to as "Formlets"
around some content in a page. These are basically content "wrapper"
sections that are tables that have a colored header and...
|
by: jk |
last post by:
Looking through WebUIValidation.js, I discovered that the standard validators
don't cater for non-numeric date formats (e.g. dd-MMM-yyyy) which I would
like to do
To keep code to a minimum, I...
|
by: DKode |
last post by:
I have developed a custom server control that displays a login page
that authenticates against AD. The server control works fine, but now I
am trying to figure out the best way to output custom...
|
by: Nick Gilbert |
last post by:
Hi,
How can I create a custom control which will wrap its content in a
header and footer?
eg:
Is it possible to create a .NET user control which can surround other
controls? eg:...
|
by: gerry |
last post by:
I am trying to create a custom container control that will only ever contain
a specific type of control.
At design time, when a control of a different type is added to the container
I would like...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
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...
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
| |