b.ID="test";
...
...
b.Attributes.Add("kinlaniscool", false);
this.Page.Controls.Add(b);The above code might add a control to the page which is a "b" tag and that will look like: <b id="testB" kinlaniscool="false">If you wanted to do something similar in a custom server control, I might do the following:protected override void Render(HtmlTextWriter output)
{
output.AddAttribute("kinlaniscool", "false");
output.AddAttribute("ID", "test");
output.RenderBeginTag(HtmlTextWriterTag.B);
output.Write("Yo!");
output.RenderEndTag();
}Basically all we are doing in the above code is overriding how the control renders its data. It will render a B tag with all the correct attributes.And that is about it.
Related Tags |
html elements [feed], html tag [feed], html object [feed], attribute [feed], attributes [feed], javascript [feed], c# [feed], .net [feed], c_sharp [feed], servercontrol [feed] |
Related Wikipedia Documents |
HTML element, C Sharp, Meta tag, Attribute, Tag soup, Dynamic HTML, Object-oriented programming, JavaScript, ECMAScript, JavaScript engine, C Sharp |
Related Amazon Books |
Applied .Net Attributes: View From Amazon UK/View From Amazon USA Head First Design Patterns: View From Amazon UK/View From Amazon USA Head Rush Ajax: View From Amazon UK/View From Amazon USA JavaScript: The Definitive Guide: View From Amazon UK/View From Amazon USA Programming ASP.NET 2.0 Core Reference: View From Amazon UK/View From Amazon USA Programming C#: View From Amazon UK/View From Amazon USA ASP.NET 2 for Dummies (For Dummies S.): View From Amazon UK/View From Amazon USA C#: View From Amazon UK/View From Amazon USA |
Related Images From Flickr |
[[posterous-content:gcbAuxfIfkAildnnwbjH]][[posterous-content:dgHhohAaxyjxgkFHjxIJ]][[posterous-content:mqfAmsBGcdbBIqfEnHhd]][[posterous-content:Eblpngydcloeihahkmck]][[posterous-content:DImmjoyxGGjFvHxFtunf]][[posterous-content:eteHjaeaCHiogEEGolxj]][[posterous-content:inDgAuDwicocrcvzorcc]] |