Questions tagged [htmltextwriter]

Writes markup characters and text to an ASP.NET server control output stream. This class provides formatting capabilities that ASP.NET server controls use when rendering markup to clients.

89 questions
15
votes
5 answers

Are there any benefits to using HtmlTextWriter if you are not going to benefit from adaptive rendering?

Outside of benefiting from Adaptive Rendering for alternate devices, does it ever make sense to write all of this…
Chris Ballance
  • 32,056
  • 25
  • 101
  • 147
14
votes
1 answer

How to add attributes correctly upon rendering with a HtmlTextWriter?

I want to add the href attribute to a link element. This is my code: System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); using (System.IO.StringWriter stringWriter = new System.IO.StringWriter(stringBuilder)) { using…
citronas
  • 17,809
  • 26
  • 85
  • 155
12
votes
6 answers

How can I get the CheckBoxList selected values, what I have doesn't seem to work C#.NET/VisualWebPart

I am creating a CheckBoxList in a class file and am using an HTMLTextWriter to render the control. I'm using the following code to store the selected values in a string: string YrStr = ""; for (int i = 0; i < YrChkBox.Items.Count; i++) { if…
anpatel
  • 1,924
  • 4
  • 19
  • 35
10
votes
4 answers

Fluent interface for rendering HTML

Rendering HTML with the HtmlTextWriter isn't incredibly intuitive in my opinion, but if you're implementing web controls in web forms it's what you have to work with. I thought that it might be possible to create a fluent interface for this that…
Patrik Hägne
  • 15,475
  • 4
  • 49
  • 59
8
votes
2 answers

Converting contents of HtmlTextWriter to a string

I have a third party tool that creates an img tag through code using HtmlTextWriter's RenderBeginTag, RenderEndTag & AddAttribute methods. I want to get the resulting HTML into a string. I tried the reflection method mentioned here but I get a …
Tony_Henrich
  • 37,447
  • 63
  • 211
  • 355
5
votes
3 answers

How to use StringWriter and HtmlWriter together without Code Analysis warnings

I'm using .net and need to get some html text, so I thought I would use the HtmlTextWriter and StringWriter together to get the well-formed html. But despite all the different ways I write the code I still get warnings from the static code analyzer…
Jon Tindel
  • 51
  • 1
  • 3
5
votes
3 answers

Using HtmlTextWriter to Render Server Controls?

I'm writing the RenderContents() method of my ASP.NET server control. The method uses an HtmlTextWriter object to render the output content. For the control I'm writing, using the HtmlTextWriter's methods seems like it will require a lot of lines of…
Dan Herbert
  • 90,244
  • 46
  • 174
  • 217
5
votes
3 answers

how to display a text with tags in jsp

I want to display a text called "welcomeJsp" In page source also i'm seeing as "welcomeJsp" But in HTML its displaying as "welcomeJsp" alone. Please guide me.
user1738638
  • 51
  • 1
  • 5
4
votes
1 answer

Is it possible to add an attribute to HtmlTextWriter WriteBreak

Is it possible to add a class to a br tag when using the HtmlTextWriter.WriteBreak method? writer.AddAttribute(HtmlTextWriterAttribute.Class, "className"); writer.WriteBreak(); I need an xHtml compliant html output and therefore the WriteBreak is…
skyfoot
  • 17,783
  • 7
  • 43
  • 70
4
votes
1 answer

Why do certain tags go a new line when using HtmlTextWriter?

I'm having a bit of a hard time trying to format my HTML when using HtmlTextWriter. It seems that some tags will automatically go to a new line and some won't. Is there a way to stop this from happening so all tags are created equally and leave the…
g5insider
  • 99
  • 9
4
votes
1 answer

How can I use HtmlTextWriter to write html comments?

I'm using HtmlTextWriter to output html to a stream. However, I'm missing a way to write html comments. Of course, I could write an extension method doing public static void WriteComment(this HtmlTextWriter writer, string comment) { …
skolima
  • 29,517
  • 26
  • 108
  • 146
3
votes
2 answers

HtmlTextWriter - Adding multiple classes to a tag

What is the best way to add multiple classes to a tag using HtmlTextWriter? What I would like to do is something like... writer.AddAttribute(HtmlTextWriterAttribute.Class, "Class1"); writer.AddAttribute(HtmlTextWriterAttribute.Class, "Class2"); …
Brett Postin
  • 10,721
  • 9
  • 58
  • 93
3
votes
3 answers

How can I create spacing and indents using HTMLTextWriter?

I would like to ask how do I create a spacing and indent using HTMLTextWriter. So far, I have tried using the html.writeline(); but it does not work. Can someone advise me on the codes? Thanks. Here is the code that I currently have: HtmlTextWriter…
athgap
  • 165
  • 1
  • 5
  • 13
3
votes
2 answers

Using HtmlTextWriter in ASP.NET MVC

I am migrating some old code where HtmlTextWriter is used extensively to render UI elements. I am migrating the code to use ASP.NET MVC 1.0. As far as I am aware, I am not using any of the HtmlTextWriter specific function (such as…
Adrian Godong
  • 8,366
  • 8
  • 37
  • 62
3
votes
8 answers

C# - object-oriented way of writing HTML as a string?

I'm trying to programmatically send an email of all of the dll files and their versions in a directory, recursively. I'd like to send the email as HTML output, using a table. Is there a good object-oriented way of doing this? I'd hate to write…
David Hodgson
  • 9,544
  • 17
  • 53
  • 77
1
2 3 4 5 6