Skip to main content

HTML CONTROL


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.
<html xmlns="http://www.w3.org/1999/xhtml" >
<script runat="server">
    Protected Sub Page_Load(ByVal sender As Object,ByVal e As EventArgs) _
Handles Me.Load
        anchor1.HRef = "/QuickStart"
    End Sub
    </script>
<head runat="server">
    <title></title>
</head>
<body>
     <h3><font face="Verdana">Simple HTML Anchor Sample</font></h3>
    <form id="form1" runat="server">
    <div>
       <p><a id="anchor1" runat="server">Go To Quick Start</a></p>
    </div>
    </form>
</body>
</html>

HTML Button Control
It 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.
<html xmlns="http://www.w3.org/1999/xhtml" >
<script runat="server">
    Protected Sub btnSample_Click(ByVal sender As Object, _
ByVal e As EventArgs)
        Span1.InnerHtml = "You clicked btnSample"
    End Sub
    Protected Sub btnSample2_Click(ByVal sender As Object,
ByVal e As EventArgs)
        Span1.InnerHtml = "You clicked btnSample2"
    End Sub
    </script>
<head runat="server">
    <title></title>
</head>
<body>
    <h3><font face="Verdana">HTMLButton Sample</font></h3>
    <form id="form1" runat="server">
    <div>
        <p>
        <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"/>
                        Click Me
        </button>
                &nbsp;With embedded image
          </p>
        <p>
        <button id="btnSample2" onserverclick="btnSample2_Click"
                 runat="server"
             style="font:8pt verdana;background-color:Green;border-
color:Black;height:30;width:100"
            onmouseover="this.style.backgroundColor='yellow'"
            onmouseout="this.style.backgroundColor='Green'">
 
            Click Me too!
         </button>
            &nbsp;With rollover effect
 
        </p>
        <span id="Span1" runat="server"></span>
    </div>
    </form>
</body>
</html>


HTMLGeneric Control
HtmlGenericControl 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).
<html xmlns="http://www.w3.org/1999/xhtml" >
<script runat="server">
    Protected Sub SubmitBtn_Click(ByVal sender As Object, _
                    ByVal e As EventArgs)
        Body.Attributes("bgcolor") = selectColor.Value
    End Sub
 
    </script>
<head runat="server">
    <title></title>
</head>
<body id="Body" runat="server">
    <h3><font face="Verdana">HTMLGenericControl Sample</font></h3>
    <form id="form1" runat="server">
    <div>
        <p>
            Select a background color the page:
            <select id="selectColor" runat="server">
                <option>White</option>
                <option>Wheat</option>
                <option>Green</option>
                <option>Red</option>
            </select>
        </p>
        <input type="submit" runat="server" value="Apply"
onserverclick="SubmitBtn_Click" />
    </div>
    </form>
</body>
</html>



HTMLImage Control
An HTML Image server control renders the image file specified by its SRC property in an HTML <img> tag.
<html xmlns="http://www.w3.org/1999/xhtml" >
<script runat="server">
    Protected Sub SubmitBtn_Click(ByVal sender As Object, _
                                  ByVal e As EventArgs)
        image1.Src = selectCereal.Value
    End Sub
    </script>
<head runat="server">
    <title></title>
</head>
<body>
    <h3><font face="Verdana">HTMLButton Sample</font></h3>
    <form id="form1" runat="server">
    <div>
        <img id="image1" runat="server" src="Grains.jpg" />
        <p>
            <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>
            </select>
            <input id="Submit1" type="submit" runat="server" value="Apply"
                onserverclick="SubmitBtn_Click" />
        </p>
    </div>
    </form>
</body>
</html>


HTML Select Control
The HTMLSelect control provides a dropdown list. This sample illustrates using the HtmlSelect HTML control.
<html xmlns="http://www.w3.org/1999/xhtml" >
<script runat="server">
    Protected Sub Apply_Click(ByVal sender As Object, _
                              ByVal e As EventArgs)
        span1.Style("background-color") = selectColor.Value
    End Sub
    Protected Sub AddToList_Click(ByVal sender As Object, _
                                  ByVal e As EventArgs)
        selectColor.Items.Add(text1.Value)
    End Sub
 
    </script>
<head runat="server">
    <title></title>
</head>
<body>
    <h3><font face="Verdana">Simple HTMLSelect Sample</font></h3>
    <form id="form2" runat="server">
    <div>
        Select a color <br />
            <select id="selectColor" runat="server">
                <option>Blue</option>
                <option>Green</option>
                <option>Lemon</option>
            </select>
            <input id="Submit1" type="submit" runat="server" value="Apply"
                            onserverclick="Apply_Click" />
        <p>
        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" />
        </p>
        <span id="span1" runat="server">
            Click the button to apply a background color to this span
        </span>
    </div>
    </form>
</body>
</html>


Comments

Popular posts from this blog

Editing Child GridView in Nested GridView

Editing Child GridView in Nested GridView In this article we will explore how to edit child gridview in the nested gridview.   Let''s write some code. Step 1:  Add scriptmanager in the aspx page. < asp : ScriptManager   ID ="ScriptManager1"   runat ="server"   EnablePageMethods ="true"> </ asp : ScriptManager > Step 2:  Add below stylesheet for modal popup. < style   type ="text/css">        .modalBackground        {              background-color : Gray;              filter : alpha(opacity=80);              opacity : 0.5;       }        .ModalWindow        {              border : solid1px#c0c0c0;              background : #f0f0f0;              padding : 0px10px10px10px;              position : absolute;              top : -1000px;       } </ style > Step 3:   Create an aspx page and add a Gridview with another gridview in the last TemplateField. The last templatefield will also contain a lable which will

Scrollable Gridview With fixheader using JQuery in Asp.net

Scrollable Gridview With fixheader using JQuery in Asp.net Introduction: In this article I will explain how to implement scrollable gridview with fixed header in asp.net using JQuery.  Description:  In Previous posts I explained lot of articles regarding Gridview. Now I will explain how to implement scrollable gridview with fixed header in asp.net. I have one gridview that contains lot of records and I used  paging for gridview  but the requirement is to display all the records without paging. I removed paging at that time gridview occupied lot of space because it contains more records to solve this problem we implemented scrollbar.  After scrollbar implementation if we scroll the gridview we are unable to see Gridview header.   To implement Scrollable gridview with fixed header I tried to implement concept with css and JavaScript but there is no luck because maintaining fixed header working in IE but not in Mozilla and vice versa to solve this browser compatibility proble

Nested GridView Example In Asp.Net With Expand Collapse

This example shows how to create Nested GridView In Asp.Net Using C# And VB.NET With Expand Collapse Functionality. I have used JavaScript to Create Expandable Collapsible Effect by displaying Plus Minus image buttons. Customers and Orders Table of Northwind Database are used to populate nested GridViews. Drag and place SqlDataSource from toolbox on aspx page and configure and choose it as datasource from smart tags Go to HTML source of page and add 2 TemplateField in <Columns>, one as first column and one as last column of gridview. Place another grid in last templateField column. Markup of page after adding both templatefields will like as shown below. HTML SOURCE 1: < asp:GridView ID ="gvMaster" runat ="server" 2: AllowPaging ="True" 3: AutoGenerateColumns ="False" 4: DataKeyNames ="CustomerID" 5: DataSour