HTML Controls are HTML elements exposed to the server so you can program against them. HTML controls expose an object model that maps very closely to the HTML elements that they render.
HTML Anchor Control
It allows programmatic access to the HTML <a> element on the server. There are two ways to use the HtmlAnchor class. The first is for navigation: using the HRefproperty to define the location of the page to link to. The second is for postback events: using the ServerClick event to programmatically handle the user’s clicking a link.
Protected Sub Page_Load(ByVal sender As Object,ByVal e As EventArgs) _ |
anchor1.HRef = "/QuickStart" |
< h3 >< font face = "Verdana" >Simple HTML Anchor Sample</ font ></ h3 > |
< form id = "form1" runat = "server" > |
< p >< a id = "anchor1" runat = "server" >Go To Quick Start</ a ></ p > |
HTML Button ControlIt allows programmatic access to the HTML <button> tag on the server. The <button> element allows Web developers to create user interface (UI) form buttons that can be composed of embedded HTML elements, including other server controls.
Protected Sub btnSample_Click(ByVal sender As Object, _ |
Span1.InnerHtml = "You clicked btnSample" |
Protected Sub btnSample2_Click(ByVal sender As Object, |
Span1.InnerHtml = "You clicked btnSample2" |
< h3 >< font face = "Verdana" >HTMLButton Sample</ font ></ h3 > |
< form id = "form1" runat = "server" > |
< button id = "btnSample" onserverclick = "btnSample_Click" runat = "server" |
style="font:8pt verdana;background-color:Green;border- |
color:Black; height = 30 ; width = 100 "> |
< img src = "Chrysanthemum.jpg" height = "20" width = "50" /> |
With embedded image |
< button id = "btnSample2" onserverclick = "btnSample2_Click" |
style="font:8pt verdana;background-color:Green;border- |
color:Black;height:30;width:100" |
onmouseover = "this.style.backgroundColor='yellow'" |
onmouseout = "this.style.backgroundColor='Green'" > |
With rollover effect |
< span id = "Span1" runat = "server" ></ span > |

HTMLGeneric ControlHtmlGenericControl provides a server control implementation for all unknown HTML Server control tags not directly represented by a specific HTML server control (examples <span>, <div>, <body> etc).
Protected Sub SubmitBtn_Click(ByVal sender As Object, _ |
Body.Attributes("bgcolor") = selectColor.Value |
< body id = "Body" runat = "server" > |
< h3 >< font face = "Verdana" >HTMLGenericControl Sample</ font ></ h3 > |
< form id = "form1" runat = "server" > |
Select a background color the page: |
< select id = "selectColor" runat = "server" > |
< input type = "submit" runat = "server" value = "Apply" |
onserverclick = "SubmitBtn_Click" /> |


HTMLImage ControlAn HTML Image server control renders the image file specified by its
SRC property in an HTML
<img> tag.
Protected Sub SubmitBtn_Click(ByVal sender As Object, _ |
image1.Src = selectCereal.Value |
< h3 >< font face = "Verdana" >HTMLButton Sample</ font ></ h3 > |
< form id = "form1" runat = "server" > |
< img id = "image1" runat = "server" src = "Grains.jpg" /> |
< select id = "selectCereal" runat = "server" > |
< option value = "Grains.jpg" >Healthy Grains</ option > |
< option value = "cornflake.jpg" >Corn Flake Cereal</ option > |
< option value = "honeyoat.jpg" >Honey Oats</ option > |
< input id = "Submit1" type = "submit" runat = "server" value = "Apply" |
onserverclick = "SubmitBtn_Click" /> |

HTML Select ControlThe HTMLSelect control provides a dropdown list. This sample illustrates using the HtmlSelect HTML control.
Protected Sub Apply_Click(ByVal sender As Object, _ |
span1.Style("background-color") = selectColor.Value |
Protected Sub AddToList_Click(ByVal sender As Object, _ |
selectColor.Items.Add(text1.Value) |
< h3 >< font face = "Verdana" >Simple HTMLSelect Sample</ font ></ h3 > |
< form id = "form2" runat = "server" > |
< select id = "selectColor" runat = "server" > |
< input id = "Submit1" type = "submit" runat = "server" value = "Apply" |
onserverclick = "Apply_Click" /> |
Don't see your color in the list above < br /> |
< input id = "text1" type = "text" runat = "server" /> |
< input id = "button1" type = "submit" runat = "server" value = "Add to List" |
onserverclick = "AddToList_Click" /> |
< span id = "span1" runat = "server" > |
Click the button to apply a background color to this span |
Comments
Post a Comment