Image Display In Label Using Asp.Net C#

Image Display In Label

Image Display Within The Label Single Time or Multiple Time Button click Event Using Asp.Net C#.


                               DEMO



                          HTML CODING


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
                <asp:Label ID="lblSingleImage" runat="server"></asp:Label>
        <asp:Label ID="lblMultipleImage" runat="server"></asp:Label>
     <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Show Image" />
        <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Show Multiple Time" />

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

</html>

                              C# CODING


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ImageDisplayLabel : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {           

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
       lblSingleImage.Text = "<img id='9' src='Koala.jpg' width='100' />";
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        lblMultipleImage.Text += "<img id='99' src='Penguins.jpg' width='100' />";
    }

}




First - Add - New WebForm - Select Label,Button 

From ToolBox





Next - Button Event - Label Assign Image Source like String 








0 comments:

Post a Comment