Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Client script in Code-Behind

Status
Not open for further replies.

olivia919

Programmer
May 19, 2005
24
US
what I am trying to do is to open a new window when a BUTTON is clicked and at the same time
I need to pass some Session variables. The problem I am having is The first time when I click the Button1, it works fine and does what i want it to do. It opens the new window and pass the var. But when I click the button for the second time, since the open new window script is already added, It will open the new window without going through the button click event. Please help...ThX!!!!!

code as the following:
Private Sub Page_Load.....
If Not Page.IsPostBack Then
Button1.Attrubites.Add("Onclick","window.open('report.aspx')")
end if
end sub

Private Sub Button1_Click....
Session("Selection") = "ByDay"
Session("Resource") = "A"
End Sub
 
It does fire the button click event each time. I've just created a new page, added a button and tested it (by adding a breakpoint) and it fires as expected with each click.

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Thanks for your answer. :)It does fire the button click event each time. But my problem is:
When I click button1 for the first time(it works perfect), The code goes like: Page_load(ADD Attribute to open new window)->Button1_click(pass a date Session("Date")='6/1/2005') to the new window) -> Open the new browser.
When I close the new window and click button1 again to pass a different var(7/1/2005). The code goes like:
Page_Load(since the attribute is already added,no action)->open the new browser->Button1_click
see my problem, the new window didn't get the 7/1/2005 I am trying to pass.
 
How do you pass this variable (the one that is a date)? Is it a session variable from the button click?

If so, you'll probably find that popup window is loading before the session variable has had the chance to be set by the button click event.

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Yes, session variables are generated based on what buttons are clicked on the form.
 
In that case my second point in my last post will probably apply

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Any suggestions? maybe this button click and client script open a form is not working well together
thanks for your help
 
You could pass it to the pop up window as a querystring rather than a session variable

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
I need to pass a session array variables based on the checkbox selections from the form as well as some session variables. querystring will probably not work at this case.
 
In that case you could make the popup page work on a kind of timer (like a "Please Wait" message) until the session variables have been populated.

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top