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
3
votes
0 answers

Code formatting with XHtmlTextWriter and Control instance

XHtmlTextWriter takes second parameter tabString. I set it to HtmlTextWriter.DefaultTabString When we use xhtmlTextWriter.WriteLine(), it indents the code. But if we use control.RenderControl(xhtmlTextWriter), it performs only one indentation for…
Annie
  • 3,090
  • 9
  • 36
  • 74
3
votes
1 answer

Render vs Write in System.Web.UI.HtmlTextWriter

I'm programatically creating a simple HTML file which is saved directly to disk. I was looking at this example: http://www.dotnetperls.com/htmltextwriter I'm confused why he mixes HtmlTextWriter's Render and Write methods, and how I should choose…
Mr. Boy
  • 60,845
  • 93
  • 320
  • 589
3
votes
2 answers

Add a title when exporting gridview data to a doc file

I have some Sql Server database, and I return the data with this method: protected DataTable GetProductsData() { if (ddTipRaport.SelectedItem.Text == "Toate Cerintele") { DataTable dt = new DataTable(); …
TBogdan
  • 737
  • 7
  • 17
  • 34
2
votes
8 answers

Creating and showing dynamic error messages (Not working inside UpdatePanel)

My web forms inherits a class called MyPageMain, which inhertis System.Web.UI.Page and is located on the App_Code folder. In this MyPageMain class I created this method, to record and output Exceptions (error messages): public string Error(Exception…
Vitor Reis
  • 989
  • 4
  • 24
  • 45
2
votes
1 answer

JQGrid export using SelectPDF, no data in linked JQGrid

I have 2 JQGrids on my ASPX page. When an Invoice is selected on the top grid, it loads the corresponding data on the second. My issue is with exporting. When I export the page using SelectPDF, the 2nd Grid View is always empty. Here is what it…
user3580480
  • 442
  • 7
  • 14
  • 45
2
votes
1 answer

In ASP.NET 2.0 how do I remove the extra tabs and line breaks from the rendered page/control output?

I have been researching this one for awhile. I found several resources on the subject and they all tend to use the same approach - override Page.Render, use the HtmlTextWriter to convert the output into a string, and then use a series of compiled…
NightOwl888
  • 55,572
  • 24
  • 139
  • 212
2
votes
3 answers

Ensuring unique ID attribute for elements within ScriptControl

I'm creating a control based on ScriptControl, and I'm overriding the Render method like this: protected override void Render(HtmlTextWriter writer) { RenderBeginTag(writer); writer.RenderBeginTag(HtmlTextWriterTag.Div); …
Andy West
  • 12,302
  • 4
  • 34
  • 52
2
votes
1 answer

How does HtmlTextWriter write to page?

I'm trying to write HTML code into my ASPX file from my C# file. This is what I have so far, just to try to get it working before I actually starting putting in stuff that I want. protected void Page_Load(object sender, EventArgs e) { …
smritz
  • 108
  • 6
2
votes
1 answer

Which is more efficient for rendering a server control in ASP.NET

I am outputting the entire HTML for my server control as follows: public override void Render(HtmlTextWriter output) { output.Write(myStringBuilder.ToString()); } myStringBuilder is a StringBuilder object that is manually built in a separate…
frankadelic
  • 20,543
  • 37
  • 111
  • 164
1
vote
2 answers

Rendering a server-side control using HTMLTextWriter makes control lose standard functionality (i.e. Click eventhandler)

I want to add Server-Side controls (CheckBoxLists & Button): ChkBoxLst1 & ChkBoxLst2 & Button1 through Code-behind and then use an HTMLTextWriter to render the control. I can't seem to be able to do this. All of the above in a Visual WebPart.…
anpatel
  • 1,952
  • 4
  • 19
  • 36
1
vote
1 answer

HTMLTextWriter to render elements in the middle of the page

Using asp .net and C# I've managed to use a HTMLTextWriter in my override Render method to render two divs. But they appear at the end of the page, how can I choose where to render these divs if I needed them to appear in a particular asp panel for…
user1017882
1
vote
2 answers

Rendering HTML from List property in Web Part

I am trying to read some values from a SharePoint List and render them in my page as HTML. However, it literally shows the HTML tags on the Web Part page and fails to render it. protected override void Render(System.Web.UI.HtmlTextWriter writer) { …
Kris Van den Bergh
  • 1,102
  • 4
  • 18
  • 31
1
vote
3 answers

C# generated dynamic controls not displaying

I have the following C# code on one of my pages: protected override void Render(HtmlTextWriter writer) { //an array named fieldNames is delcared here writer.Write("
"); …
1
vote
2 answers

WebView2 - Update innerHTML using HtmlTextWriter

Is it possible to set/update the innerHTML with the ExecuteScriptAsync method in WebView2, or is there another way around it? I created the below method to update the DOM. It works fine except for innerHTML private async Task…
Zimo
  • 312
  • 5
  • 21
1
vote
3 answers

HtmlTextWriter doesn't flush upon disposal?

I need to write some text with style (like color, fonts) so I decided to use html. I found that HtmlTextWriter is a class used for writing html file. However, I found that I must manually close or flush it otherwise nothing is written to the file.…
LLS
  • 2,128
  • 2
  • 23
  • 36