Hey guys, long time no see! I hope you are all doing well.
I have a puzzling problem with an ASP.NET C# homepage that I'm playing with. I hope that your suggestions can help me!
Basically, I just want to register clicks to external links on my website, and open up the URLs in a new window:
- A user clicks on a link to an external site
- Serverside code ensures that the click is registered in the database
- The browser opens up a new window (ie. _BLANK) with the URL of the link
Pretty simple, huh?
Now, the troublesome part is that in my aspx page I define the link as a LinkButton so I have the OnClick event to put my c# serverside code in, ie. could be something like:
Code:
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click" CssClass="linkbutton_style">LinkButton</asp:LinkButton>
In the aspx.cs page I then have:
Code:
protected void LinkButton1_Click(object sender, EventArgs e)
{
//Do database stuff here
Response.Redirect(HttpUtility.HtmlDecode(whatever-link));
}
The thing is, the Response.Redirect does not have the option to open up the link in a new window (ie. there is no way to do a _BLANK this way).
What to do?
What I really want is a control that lets me have an OnClick event AND give me the option of passing the user along to the other website in a new window. I've tried all sorts of standard controls.
I do NOT want to use javascript to open up a new window, since most browsers will come up with a notification of this nowadays - so this is not an option.
All suggestions are appreciated