Insert record in database and open Highslide javascript pop-up with one click.

Hi, experts - I am in need of your assistance.

My scenario is this: We offer training videos that authorized users can view on our website. When a user clicks a link to a video, we want to capture that click (along with some session info) in a database table so we know it was clicked on, and also display the video within a Highslide javascript pop-up window.

So far I've been able to do either or, but not together. I've tried LinkButtons, Hyperlinks, and Buttons. I'm hoping that this is possible and that I just plain don't know the syntax involved.

Below is the code I used for my LinkButton. In this example, clicking the LinkButton does insert into the database and the Highslide window tries to open, but just sits on the "Loading" graphic and never loads. Does anything glaring look amiss? Is there a better way to do this?

Thanks for any help you might provide.
Protected Sub LinkButton1_Click(sender As Object, e As System.EventArgs) Handles LinkButton1.Click
        Dim ConSql As String = ConfigurationManager.ConnectionStrings("MyConnectionString").ConnectionString
        Dim ConIns As String = "INSERT INTO DemosClicked (txtEntryCode, txtRequestor, txtModuleClicked) VALUES (@ec, @req, @c)"
        Dim sqlConnInsert As SqlConnection
        sqlConnInsert = New SqlConnection(ConSql)

        Dim addcommand As New SqlCommand(ConIns, sqlConnInsert)
        addcommand.Parameters.Add(New SqlParameter("@ec", Session("EntryCodeVar")))
        addcommand.Parameters.Add(New SqlParameter("@req", Session("RequestorVar")))
        addcommand.Parameters.Add(New SqlParameter("@c", Session("RequestorVar")))

        LinkButton1.Attributes.Add("postbackurl", "/demos/mydemo.htm")
        LinkButton1.Attributes.Add("onclick", "return hs.htmlExpand(this, {objectType:  'iframe', width: '640' } )")
    End Sub

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
That is starting to sound like a disconnect caused by the post-back for the LinkButton click, and the client-side JavaScript component.  It is interesting that you are adding attributes for every LinkButton click.  You might want to think about a different approach, such as calling server-side code from a JavaScript (AJAX page method).

Using Page Methods in ASP.NET AJAX
Kamal KhaleefaInformation Security SpecialistCommented:
if you want just after completing your code
add response.redirect(demos/mydemo.htm")
John0214Author Commented:
Thank you both for your comments/suggestions. I decided on a different approach. Instead of wiring the two events to one LinkButton (which I wasn't having success doing), I opted to change the LinkButton to a regular hyperlink that opens the Highslide window, then do the database insert on the Highslide pop-up window's Page Load.

Thanks again!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
John0214Author Commented:
Good suggestions from experts, but the resolution of the original question was not achieved. Instead, I got the desired result by changing the way the application worked. Thanks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.