views:

18

answers:

1

Normally, unknown attributes of a webcontrol are passed through to to the rendered element in the browser. So the following works.

<asp:label runat="server" Text="Label Text" helpId="101" />

However, if you use a namespaced attribute like the following

<asp:label runat="server" Text="Label Text" myNs:helpId="101" /></div>

The attribute is not rendered to the client, even when the custom namespace is declared in the html element like:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:myNs="http://www.acme.com/htmlext"&gt;

Does anyone know of a way to get this to render to the client, without having to use a custom control. A module or other globally "pluggable" solution would be acceptable.

A: 

Found this article on MSDN... looks promising. But you will need to create a custom webcontrol.

WebControl.AddAttributesToRender Method

Adds HTML attributes and styles that need to be rendered to the specified HtmlTextWriterTag.

[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")] 
  protected override void AddAttributesToRender(HtmlTextWriter writer) 
  {

     writer.AddAttribute("myNs:helpId", "101");
     base.AddAttributesToRender(writer);

  }
thomasvdb
Thanks, I saw this as well but I was hoping to locate something generic that would allow it to work with all existing controls.
Richard Collette