Joma Rajab

Joma Rajab

  • NA
  • 110
  • 51.5k

How to write code behind for <a> tag

Aug 24 2016 12:16 PM
I need to use a tag with click event and the href link I need to write it in code behind
when the link is clicked it will be opened on iframe by writing iframe id in the target of a tag

I tried the code below

please help
Thank you  
 
  1. <a id="urlbb" runat="server" >web1  
  2. <asp:PlaceHolder ID="url" runat="server" Visible="false">  
  3. <iframe name="aa" width="100%" height="800px" style="margin-top:50px"></iframe></asp:PlaceHolder>  
  4. <asp:PlaceHolder ID="mainbody" runat="server" Visible="true">  
  5. .  
  6. .  
  7. .  
  8. .  
  9.   
  10. </asp:PlaceHolder>  
  11. Code behind   
  12. protected void urlbb_ServerClick(object sender, EventArgs e)  
  13. {  
  14. mainbody.Visible = false;  
  15. url.Visible = true;  
  16. urlbb.Target = "aa";  
  17. urlbb.HRef = "http://www.bradford.ac.uk/it-services/students/email/";  
  18. }  

Answers (7)