Reputation: 2046
I have a strange situation. I have a website where hyperlinks are dynamically generated (as user controls) which have the target
attribute set to _blank
as I need it to open in a new window. Due to the nature of what the new page is displaying I need to audit when the user clicks on it. I already have auditing functionality set up so I am looking for a way to run code before the link opens the new page.
If it was in internal page on the same site i could simply have the hyperlink as a command button which runs the audit code and then does a Response.Redirect()
.
I don't have any control over the target pages because they are on a different website. I would be interested to her how others have done this and whether it's possible to do it in the way that I've explained!
Upvotes: 1
Views: 657
Reputation: 6462
Since you want to open the link in a new window (tab) I would suggest a JavaScript Window.Open and before that a AJAX call for your Audit. This will be must fast and better UX.
Upvotes: 1
Reputation: 70324
You can still do the Response.Redirect()
technique, or am I missing something here? Have the real hyperlinks passed as parameters to your audit page...
Upvotes: 1
Reputation: 21713
Change your links to be a handler on your site that does the auditing and then redirects. So your links would be something like
<a href="/MyAuditingHandler.ashx?targetUrl=http://www.externalsite.com" target="_blank"></a>
Your handler audits, reads the targetUrl
parameter and then redirects.
Upvotes: 2