mfeingol / htmltextwriter Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
The method name AddStyleAttrbiute(string, string) appears to be a typo. Here is a patch to fix it.
diff --git a/Source/HtmlTextWriter/HtmlTextWriter.cs b/Source/HtmlTextWriter/HtmlTextWriter.cs
index ebad04b..a1449a9 100644
--- a/Source/HtmlTextWriter/HtmlTextWriter.cs
+++ b/Source/HtmlTextWriter/HtmlTextWriter.cs
@@ -107,7 +107,9 @@ namespace System.Web.UI
public void AddStyleAttribute(HtmlTextWriterStyle key, string value) => this.AddStyleAttribute(key, value, true);
public void AddStyleAttribute(HtmlTextWriterStyle key, string value, bool encode) => AddStyleAttribute(key.ToName(), value, encode);
- public void AddStyleAttrbiute(string name, string value) => this.AddStyleAttribute(name, value, true);
+ [Obsolete("Typo in method name preserved for binary compatibility. Use the corrected method AddStyleAttribute(string, string).")]
+ public void AddStyleAttrbiute(string name, string value) => this.AddStyleAttribute(name, value);
+ public void AddStyleAttribute(string name, string value) => this.AddStyleAttribute(name, value, true);
public void AddStyleAttribute(string name, string value, bool encode)
{
if (encode)
StringWriter stringWriter = new StringWriter();
using (HtmlTextWriter writer = new HtmlTextWriter(stringWriter, string.Empty))
{
writer.WriteBeginTag("table>");
writer.WriteBeginTag("tr>");
writer.WriteBeginTag("th>"); writer.Write("RouteID"); writer.WriteEndTag("th");
writer.WriteEndTag("tr");
writer.WriteEndTag("table");
}
In the Dispose function this.InnerWriter.Dispose(); is called.
In the original version https://referencesource.microsoft.com/#System.Web/UI/HTMLTextWriter.cs dispose was not overwritten and the inner writer is left open. This can lead to exceptions when porting code.
Having said that, changing back to the original behaviour could break code that is already using this lib.
In general the class should not dispose things that it did not create.
In using HtmlTextWriter to write directly to the response stream in asp.net core, those writes need to be async.
HtmlTextWriter does support some async methods to do writes, but it lacks async alternatives for methods like WriteFullBeginTag, WriteEndTag, WriteBeginTag and similar methods.
For <TextArea>
tags, the value of the TextArea is in between the Tags, ex, <TextArea> In a Text area </TextArea>
.
The issue is that calling HtmlTextWriter.Write()
will always add tabs / new lines after the closing tab, meaning the text area will include those newlines / tabs in the value on the page.
It seems like the .NET HtmlTextWriter only adds tabs when / after calling WriteNewLine()
, but, if Write()
is only ever called, then no tabs / no newlines would be added.
Recreation steps: Render a <TextArea>
tag. Either look at the InnerWriter's
value or use jQuery.val()
on the rendered element to see that it has tabs / new lines in it.
Requested Functionality: There should be a way to write a value without having tabs/ newlines inserted after a closing tag, >
.
Hi Max,
.net core is missing AddStyleAttribute. Can you please add AddStyleAttribute in HTMLTextWriter?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.