Triggering both client and server side scripts

  • Thread starter Thread starter Karim
  • Start date Start date
K

Karim

I have a button that opens a new Window using client side Javascript. The
button also has server side script (.._click) that saves some session
variables to be used in the new Window.

The problem is that the server side function does not fire.

Karim
 
Hi Karim,

Here's some code that might work for you. Not sure whether the setting of
the Session variable will be done in time for the secondary window to fetch.
Depends on the speed of the server, I suppose.

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Button1.Attributes.Add _
("onclick", "window.open('sec.aspx','sec');return true;")
End Sub

Private Sub Button1_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Session("stored") = "here is the value at " & _
Now.ToLongTimeString
End Sub
 
Hi Karim,

Here's some code that might work for you. Not sure whether the setting of
the Session variable will be done in time for the secondary window to fetch.
Depends on the speed of the server, I suppose.

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Button1.Attributes.Add _
("onclick", "window.open('sec.aspx','sec');return true;")
End Sub

Private Sub Button1_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Session("stored") = "here is the value at " & _
Now.ToLongTimeString
End Sub


Thanks. Your code resembles what I have. The problem is that the button
click doesn't fire. I want to execute code in the click event first to set
the session variables, then open window fires up to open a new window whose
page_load event reads in the session variables that were set by the
parent's window. I guess I will have to send the parameters through a
querystring which will will built dynamically in the open window script.
The variables are some form fields.

Does anyone have a better way of doing this?

Karim
 
Thanks. Your code resembles what I have. The problem is that the button
click doesn't fire. I want to execute code in the click event first to set
the session variables, then open window fires up to open a new window whose
page_load event reads in the session variables that were set by the
parent's window. I guess I will have to send the parameters through a
querystring which will will built dynamically in the open window script.
The variables are some form fields.

Does anyone have a better way of doing this?

Karim

Well now after many tries I found that the click does fire sometimes. It
sometimes gets fired before the new Window is opened, sometimes gets fired
after the new Window is opened and sometimes the click event never fires.
This is very inconsistent!

Karim
 
Back
Top