Search

Tuesday, September 24, 2013
0 comments

How to access Html Image in code in ASP.NET

5:50 AMTuesday, September 24, 2013

The HtmlImage class

The HtmlImage Class creates an HTML <img> element, which is used to display images on the web page. Using the properties of this class, you can change the image size and the image displayed as well as the alignment of the image with respect to other HTML elements. The HTML Image class gives you access to the HTML,<img> elements in server code.

Public Properties of the HtmlImage Class

Property
Description
Align
Obtains or sets the image’s alignment with respect to other HTML elements.
Alt
Obtains or sets the alternative text to display if an image cannot be displayed.
Border
Obtains or sets the width of the image’s border
Height
Obtains or sets the image’s height
Src
Obtains or sets the URL of the image
Width
Obtains or sets the image’s width

Lets take an Simple example
<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    protected void server_click(Object sender, EventArgs e)
    {
        first.InnerHtml = "Welcome Message";
       
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
 
        Access Html Image in Code page<br />
        <input type="image" runat ="server" src ="submit.jpg" id="image1" onserverclick ="server_click" />
        <div id="first" runat ="server">
        </div>
        <br />
 
    </div>
    </form>
</body>
</html>


Output
How to access Html Image in code in ASP.NET

Protected by Copyscape Online Copyright Protection Software

0 comments :

Post a Comment

 
Toggle Footer
Top