Sunday, 21 October 2012

explicitly user defined dropdown image control - ASP.NET



here the code below(.aspx)

<%@ 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 Page_Load(object sender, EventArgs e)
    {
    }
protected void Button1_Click(object sender, EventArgs e)
    {
        Image1.ImageUrl = @"~/p1/"+DropDownList1.SelectedItem.ToString()+".jpg";
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div style="height: 402px">

        <br />
&nbsp;&nbsp;&nbsp;
        <asp:DropDownList ID="DropDownList1" runat="server">
            <asp:ListItem>i1</asp:ListItem>
            <asp:ListItem>i2</asp:ListItem>
            <asp:ListItem>i3</asp:ListItem>
            <asp:ListItem>i4</asp:ListItem>
        </asp:DropDownList>
&nbsp;
        <asp:Image ID="Image1" runat="server" Height="172px" Width="233px" />
        <br />
        <br />
&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Button ID="Button1" runat="server" Text="SHOW" onclick="Button1_Click" />

    </div>
    </form>
</body>
</html>


No comments:

Post a Comment

Tech N Science © 2013