asp.net - show an Image on Click of a LinkButton Control -
how show image in contentplaceholder4 on click of link button placed on contentplaceholder3.
i have master page , 1 content page. on master page have link instruments clicking on redirected content page instruments. have 10 link button controls on content page , want on click of each link button corresponding image should open on same content page in different cntentplaceholder. please guide me how add code link button click , how render iamge on click of link button. following code have added till now.
**this master page** <%@ master language="c#" autoeventwireup="true" codefile="masterpage.master.cs" inherits="masterpage" %> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <asp:contentplaceholder id="head" runat="server"> </asp:contentplaceholder> <style type="text/css"> .style1 { } .style2 { width: 162px; } </style> </head> <body> <form id="form1" runat="server"> <div> <img src="images/main.png" style="background-color: #99ff99; border-top-color: #800000; width: 1082px; height: 105px;" /> </div> <a href="home.aspx">home</a> <a href="instruments.aspx">instruments</a> <a href="login.aspx">login</a> <a href="adress.aspx">address</a> <table style="width: 100%; height: 288px; margin-top: 11px;"> <tr> <td bgcolor="#ff0066" align="center" class="style2" style="text-align: center; vertical-align: top;"> <asp:contentplaceholder id="contentplaceholder3" runat="server"> </asp:contentplaceholder> </td> <td bgcolor="#33cccc" class="style1"> <asp:contentplaceholder id="contentplaceholder4" runat="server"> </asp:contentplaceholder> </td> </tr> </table> </form> </body> </html> **this content page** <%@ page title="" language="c#" masterpagefile="~/masterpage.master" autoeventwireup="true" codefile="instruments.aspx.cs" inherits="instruments" %> <asp:content id="content3" contentplaceholderid="head" runat="server"> <link href="stylesheet.css" rel="stylesheet" type="text/css" /> </asp:content> <asp:content id="content1" contentplaceholderid="contentplaceholder3" runat="server"> <asp:linkbutton id="linkbutton1" runat="server" onclick="lkbutton_click">sitar</asp:linkbutton><br /> <asp:linkbutton id="linkbutton2" runat="server">harmonium</asp:linkbutton> <br /> <asp:linkbutton id="linkbutton3" runat="server">tabla</asp:linkbutton> <br /> <asp:linkbutton id="linkbutton4" runat="server">drum</asp:linkbutton> <br /> <asp:linkbutton id="linkbutton5" runat="server">guitar</asp:linkbutton> <br /> <asp:linkbutton id="linkbutton6" runat="server">sarod</asp:linkbutton> <br /> <asp:linkbutton id="linkbutton7" runat="server">flute</asp:linkbutton> <br /> <asp:linkbutton id="linkbutton8" runat="server">santoor</asp:linkbutton> <br /> <asp:linkbutton id="linkbutton9" runat="server" onclick="linkbutton9_click">keyboard</asp:linkbutton> <br /> <asp:linkbutton id="linkbutton10" runat="server">linkbutton</asp:linkbutton> </asp:content> <asp:content id ="c2" contentplaceholderid ="contentplaceholder4" runat="server"> <asp:image id ="i1" imageurl ="~/images/f.png" > <asp:image /> </asp:content>
in design page use this.
<asp:content contentplaceholderid="contentplaceholder4" runat="server"> <img id="img1" runat="server" /> </asp:content>
and in code behind link button click event below:
protected void lkbutton_click(object sender, eventargs e) { img1.src = "~/images/sonata-logo.png"; }
i tested it's working fine. put correct path of image show. thanks
Comments
Post a Comment