|
using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
namespace David.Nelson.UI.Web
{
/// <summary>
/// An HtmlTextWriter that provides granular control over
/// how attributes are written.
/// </summary>
public class SelectiveHtmlTextWriter : HtmlTextWriter
{
public SelectiveHtmlTextWriter(HtmlTextWriter writer)
: base(writer.InnerWriter)
{
}
public event SubstituteValueEventHandler WritingAttribute;
public override void WriteAttribute(string name, string value, bool fEncode)
{
string valToWrite = value;
SubstituteValueEventArgs args = new SubstituteValueEventArgs(name, value);
if (WritingAttribute != null)
{
WritingAttribute(this, args);
if (args.Cancel == false)
valToWrite = args.NewValue;
}
if (args.Cancel == false)
base.WriteAttribute(name, valToWrite, fEncode);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I have been doing web development for about 11 years. I specialize in Dynamic HTML, C#, and SQL database design.