• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1712
  • Last Modified:

Click hyperlink programmatically

I have an <a> tag in an aspx page with onclick javascript attached to it.  I also have a button with a subroutine in the code behind doing some stuff.  I want the user to click the button, do the sub, then have it click that <a> automatically to do the javascript.  How can I do this?  I've tried casting the <a> as an mshtml.IHTMLElement, then using the .click action, but that didn't work.

Basically I found a javascript (GB_Show) called Greybox which pops a great preview window that I want the Account Detail page to show in.   Just clicking the link works great, but I need to do a database update and set a session variable, thus the need for a sub in the code behind.
code behind for the button:
 
  Public Sub btnRedirect_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRedirect.Click
        Dim f As mshtml.IHTMLElement = DirectCast(Me.TestA, mshtml.IHTMLElement)
        f.click()
    End Sub
 
 
code for the front end of the button and the anchor
 <asp:Button  ID="btnRedirect" runat="server" Text="Acknowledge and go to Account Detail" Width="300" />
                          <a id="TestA" runat="server" onclick="return GB_show('Account detail', 'http://webserver/account_detail.aspx', 600, 800)" >
                                                            Email - outbound</a>

Open in new window

0
flagshipcredit
Asked:
flagshipcredit
  • 2
1 Solution
 
flagshipcreditAuthor Commented:
No dice with the onclick.
0
 
flagshipcreditAuthor Commented:
I figured it out...I removed the <a> completely, and used ScriptManager.RegisterStartupScript on the button.

0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now