Hello forum,
How to pass Image from imagebutton to image control in another web form
I have images inside image button. I want to click on an image button and pass the image inside the image-button on to an image control in another web form.
When I click on a particular image it should pass that image clicked to the next form to display. I really do not know how to do it in code behind (C#).
Please can anybody help me?
Here is my HTML for the two web forms
HTML (Default.aspx)
<div class="container" style="text-align: center;">
<div class="form-horizontal">
<div class="col">
<div class="container-fluid2" style="background-color: #ffffff; width: auto;">
<div class="child2" id="midcont2" style="width: 100%;">
<asp:ImageButton ID="ImageButton1" runat="server" Width="150px" Height="200px" />
<asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/images/cardimg/gray.png" Width="150px" Height="200px"/>
<asp:ImageButton ID="ImageButton3" runat="server" ImageUrl="~/images/cardimg/bluestr.png" Width="150px" Height="200px" />
<asp:ImageButton ID="ImageButton4" runat="server" ImageUrl="~/images/cardimg/lightgreen.png" Width="150px" Height="200px"/>
<asp:ImageButton ID="ImageButton5" runat="server" ImageUrl="~/images/cardimg/slantblue.png" Width="150px" Height="200px" OnClick="ImageButton5_Click" PostBackUrl="~/TemporaryIDCard.aspx?=" +~Images//>
<asp:ImageButton ID="ImageButton6" runat="server" Width="150px" Height="200px"/>
<asp:ImageButton ID="ImageButton7" runat="server" Width="150px" Height="200px" />
<asp:ImageButton ID="ImageButton8" runat="server" Width="150px" Height="200px"/>
<asp:ImageButton ID="ImageButton9" runat="server" Width="150px" Height="200px" />
<asp:ImageButton ID="ImageButton10" runat="server" Width="150px" Height="200px"/>
<asp:ImageButton ID="ImageButton11" runat="server" Width="150px" Height="200px" />
<asp:ImageButton ID="ImageButton12" runat="server" Width="150px" Height="200px"/>
</div>
</div>
</div>
</div>
</div>
HTML(Default2.aspx)
<div class="col">
<div class="container-fluid2" style="background-color: #ffffff; width: auto;">
<div class="child" id="midcont">
<asp:Image ID="Image1" runat="server" width="350px" Height="500px"/>
<div id="child1">
<div id="chill">
<asp:Image ID="Image4" runat="server" BorderStyle="None" Width="100px" Height="110px" />
</div>
<div id="nann" style="right: 35%;">
<asp:Label ID="Label4" runat="server" Text="Samuel Tochi James" Font-Size="9pt" Width="150"></asp:Label>
</div>
<div class="change" id="color"></div>
</div>
</div>
</div>
</div>
I dont really know how to do this, but I t ried to use this
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect(string.Format("Default2.aspx");
}
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect(string.Format("Default2.aspx"));
}