Friday, 21 October 2011

How to open a link button in a new browser window?



I have text box and beside to it I have a linkbutton showing the link that is present in the text box. I am getting the URL from the website into the text from database.I need to open the link button in a new browser window.


aspx page

ASP.NET Syntax (Toggle Plain Text)
  1. <asp:Label ID="lblBusinessURL" runat="server" Text="Label"></asp:Label>
  2.  
  3. <asp:LinkButton ID="lnkBusinessURL" runat="server" ></asp:LinkButton>


aspx.cs page
ASP.NET Syntax (Toggle Plain Text)
  1. string businessurl;
  2. businessurl = DSabc.Tables[0].Rows[0]["BusinessURL"].ToString();
  3. if (businessurl.Contains ("http://"))
  4. {
  5. lblBusinessURL.Text = "<a href=" + businessurl + ">" + businessurl + "</a>";
  6. }
  7. else {
  8. lblBusinessURL.Text = "<a href=http://" + businessurl + ">" + businessurl + "</a>";
  9.  
  10. }

No comments:

Post a Comment