Pages

Tuesday, 31 January 2012

Changing the ImageUrl property dynamicaly in ASP.NET

The Image server control enables you to work with the images that appears on your Web Page
from the server side code .It's a simple server control,but it can giv you the power to determine
how your images are displayed on the browser screen.A typical image control is constructed in the following manner.
<asp:Image ID="Image1" Runat="server" ImageUrl="~/MyImage1.gif" />
The following example shows how to change the ImageUrl property of the image control dynamicaly.
VB
<script runat="server">
   Protected Sub Button1_Click(ByVal sender As Object ,ByVal e As System.EventArgs)
                Image1.ImageUrl="~/MyImage2.gif"
   End Sub
</script>
C#
protected void Button1_Click(object sender , EventArgs e)
{
        Image1.ImageUrl = "~/MyImage2.gif ";
}
            

No comments:

Post a Comment