Monday 2 June 2014

asp.net 12: dropdownlist & imagebox

Program to select movies name from dropdownlist and display picture in imagebox

-----------------------------------------DESIGN-----------------------------------------------------
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
            <asp:ListItem Selected="True">Select Any Movie</asp:ListItem>
            <asp:ListItem Value="Ishqkjade">Ishqjade</asp:ListItem>
            <asp:ListItem>Golmal3</asp:ListItem>
            <asp:ListItem>The Dark knite rises</asp:ListItem>
            <asp:ListItem>Amezing Spiderman</asp:ListItem>
            <asp:ListItem>Suparman Returns</asp:ListItem>
        </asp:DropDownList>
        <br />
        <br />
        <asp:Image ID="Image1" runat="server" Height="400px" />
   
    </div>
   
    <p>
        &nbsp;</p>
    <asp:Label ID="Label1" runat="server" Font-Bold="True"
        Font-Names="Times New Roman" ForeColor="#6600CC" Text="Label"></asp:Label>
    </form>
</body>
</html>

-----------------------------------------code---------------------------------------------------------

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
        If DropDownList1.SelectedIndex = "1" Then
            Image1.ImageUrl = "~\Images\Ishaqzaade - Front Cover.jpg"
            Label1.Text = "You selected Ishaqzaade"
        ElseIf DropDownList1.SelectedIndex = "2" Then
            Image1.ImageUrl = "~\Images\Golmaal 3 - Front.jpg"
            Label1.Text = "You selected Golmal3"
        ElseIf DropDownList1.SelectedIndex = "3" Then
            Image1.ImageUrl = "~\Images\10_2.jpg"
            Label1.Text = "You selected The Dark Knite Rieses"
        ElseIf DropDownList1.SelectedIndex = "4" Then
            Image1.ImageUrl = "~\Images\9_2.jpg"
            Label1.Text = "You selected Amazing Spiderman"
        ElseIf DropDownList1.SelectedIndex = "5" Then
            Image1.ImageUrl = "~\Images\12_2.jpg"
            Label1.Text = "You selected Suparman Returns"
        End If
    End Sub

End Class
-----------------------------------------output----------------------------------------------------

 
umesh sohaliya
codestrew

No comments:

Post a Comment