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

Override Render method in Label Control

Hello,

I have a simple asp:label control that I want to write some complicated HTML
to. Currently I have this code and it works fine:

myLable.Text = "<p>this is my text</p>"

Bust as my HTML gets more complicated I want to be able to use the
HTMLTextWriter to write the HTML like so:

writer.Write (@"

<p>this is my text</p>
<p>this is more text</p>
<p>this is alot more text</p>

")

What is the best way to go about this?

Thx
Nov 19 '05 #1
3 6045
you could create a new HtmlTextWriter wrapped around a stringwriter, to
build the string, or create a new control (my choice).

-- bruce (sqlwork.com)

"Jason Dean" <jd******@yahoo.com> wrote in message
news:N3******************@fe06.lga...
| Hello,
|
| I have a simple asp:label control that I want to write some complicated
HTML
| to. Currently I have this code and it works fine:
|
| myLable.Text = "<p>this is my text</p>"
|
| Bust as my HTML gets more complicated I want to be able to use the
| HTMLTextWriter to write the HTML like so:
|
| writer.Write (@"
|
| <p>this is my text</p>
| <p>this is more text</p>
| <p>this is alot more text</p>
|
| ")
|
| What is the best way to go about this?
|
| Thx
|
|
Nov 19 '05 #2
How exactly does this work? I've tried writing to a variable (ideal choice)
and can't seem to figure it out. Do you have any examples or links you
could send me?

Thanks soooooo much!

-Jason

"bruce barker" <no***********@safeco.com> wrote in message
news:Ow**************@TK2MSFTNGP11.phx.gbl...
you could create a new HtmlTextWriter wrapped around a stringwriter, to
build the string, or create a new control (my choice).

-- bruce (sqlwork.com)

"Jason Dean" <jd******@yahoo.com> wrote in message
news:N3******************@fe06.lga...
| Hello,
|
| I have a simple asp:label control that I want to write some complicated
HTML
| to. Currently I have this code and it works fine:
|
| myLable.Text = "<p>this is my text</p>"
|
| Bust as my HTML gets more complicated I want to be able to use the
| HTMLTextWriter to write the HTML like so:
|
| writer.Write (@"
|
| <p>this is my text</p>
| <p>this is more text</p>
| <p>this is alot more text</p>
|
| ")
|
| What is the best way to go about this?
|
| Thx
|
|

Nov 19 '05 #3
the control is simple, define it in the page behind, change the tag on the
aspx page, and you're done.

public class mylabel : Label
{
protected override Render(HtmlTextWriter output)
{
output.Write("whatever I want");
}
}
-- bruce (sqlwork.com)

"Jason Dean" <jd******@yahoo.com> wrote in message
news:90*******************@fe06.lga...
| How exactly does this work? I've tried writing to a variable (ideal
choice)
| and can't seem to figure it out. Do you have any examples or links you
| could send me?
|
| Thanks soooooo much!
|
| -Jason
|
| "bruce barker" <no***********@safeco.com> wrote in message
| news:Ow**************@TK2MSFTNGP11.phx.gbl...
| > you could create a new HtmlTextWriter wrapped around a stringwriter, to
| > build the string, or create a new control (my choice).
| >
| > -- bruce (sqlwork.com)
| >
| > "Jason Dean" <jd******@yahoo.com> wrote in message
| > news:N3******************@fe06.lga...
| > | Hello,
| > |
| > | I have a simple asp:label control that I want to write some
complicated
| > HTML
| > | to. Currently I have this code and it works fine:
| > |
| > | myLable.Text = "<p>this is my text</p>"
| > |
| > | Bust as my HTML gets more complicated I want to be able to use the
| > | HTMLTextWriter to write the HTML like so:
| > |
| > | writer.Write (@"
| > |
| > | <p>this is my text</p>
| > | <p>this is more text</p>
| > | <p>this is alot more text</p>
| > |
| > | ")
| > |
| > | What is the best way to go about this?
| > |
| > | Thx
| > |
| > |
| >
| >
|
|
Nov 19 '05 #4

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

Similar topics

4
by: Jon | last post by:
Hi! I'm creating a custom Server Control which implements the method in the subject line (Protected override void CreateChildControls) In here I have the following code: LBL myLbl = new...
1
by: DesignerX | last post by:
I want to draw the radiobuttons (each listitem) in a different place than the default of under or beside each other. Does anyone know how this is possible? Thanks, Stan
2
by: Frank | last post by:
Hi all, I want to derive a class from DataGrid so that I can have a label on the top. But when I tried to add the control to my form, I got an error "Specified cast is not valid" on the line:...
4
by: Zuel | last post by:
Hi Folks. So I have a small problem. My DoPostBack function is not writen to the HTML page nor are the asp:buttons calling the DoPostBack. My Goal is to create a totaly dynamic web page where...
3
by: John Hughes | last post by:
I'm trying to add a user control to a form via the pages render method and I get the following error : "Control 'Button1' of type 'Button' must be placed inside a form tag with runat=server" ...
1
by: Urs | last post by:
Hi the user control below renders OK when added in the designer. Why does it NOT render when added programmatically? Do I have to instruct the control somehow to render, or do I miss something?...
0
by: milmus tender | last post by:
Hi, we have some customized EditorParts, which inherits from a DefaultEditor. This DefaultEditorPart inherits from the standard EditorPart-Class. In this DefaultEditorPart we override the...
3
by: Allan Ebdrup | last post by:
We're pretty new to ASP.Net 2.0 and we're having a discussion about best practice when developing custom server web controls. I can see that in for example the Wizard control the table contained...
1
by: Joshua | last post by:
I'm creating a web control that has an image and a text box. I would like to then override the Visible and Text property of the usercontrol, so when you reference the visible property of the user...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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)...
0
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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.