C
crferguson
Hello all! I'm thinking this one has probably been beaten to death in
the past, but I can't find an answer to this specific issue I'm having
with a javascript attached to a linkbutton.
What I'm doing is I have a page with a dozen or so linkbuttons on it.
The linkbuttons open a popup information window containing additional
details about some categories on the parent page.
Heres the problem: the parent page is pretty long and some of those
linkbuttons are near the bottom. So, when I click one of those
linkbuttons at the bottom, it does a postback, opens the popup window,
and -->makes the parent page shoot back up to the top due to the
reload<--. This means every time a user clicks one of those links they
have to scroll back to the bottom of the parent page to return to their
work.
I figured the best solution to this was to stop the postback by adding
"return false" to the script. But if I add "return false" to the java
script the popup window doesn't open. Does someone know why the
"return false" stops the popup from opening? Here's my code:
strScript = "<script language='javascript'>"
strScript += "window.open('" & Global.EmployeeInfoPage
& "',"
strScript += "'emp" & eEmp.PositionNumber &
"','toolbar=no,"
strScript += "addressbar=no,menubar=no,"
strScript += "left=40,top=40,"
strScript += "width=620,height=165');"
strScript += "</script>"
p = HttpContext.Current.Handler
p.RegisterClientScriptBlock("NewEntry", strScript)
That example works, but causes the postback on the requesting page.
Adding the "return false;" right before the last line "</script>" stops
the popup from opening...
Thank you all for any insights!
Cory
the past, but I can't find an answer to this specific issue I'm having
with a javascript attached to a linkbutton.
What I'm doing is I have a page with a dozen or so linkbuttons on it.
The linkbuttons open a popup information window containing additional
details about some categories on the parent page.
Heres the problem: the parent page is pretty long and some of those
linkbuttons are near the bottom. So, when I click one of those
linkbuttons at the bottom, it does a postback, opens the popup window,
and -->makes the parent page shoot back up to the top due to the
reload<--. This means every time a user clicks one of those links they
have to scroll back to the bottom of the parent page to return to their
work.
I figured the best solution to this was to stop the postback by adding
"return false" to the script. But if I add "return false" to the java
script the popup window doesn't open. Does someone know why the
"return false" stops the popup from opening? Here's my code:
strScript = "<script language='javascript'>"
strScript += "window.open('" & Global.EmployeeInfoPage
& "',"
strScript += "'emp" & eEmp.PositionNumber &
"','toolbar=no,"
strScript += "addressbar=no,menubar=no,"
strScript += "left=40,top=40,"
strScript += "width=620,height=165');"
strScript += "</script>"
p = HttpContext.Current.Handler
p.RegisterClientScriptBlock("NewEntry", strScript)
That example works, but causes the postback on the requesting page.
Adding the "return false;" right before the last line "</script>" stops
the popup from opening...
Thank you all for any insights!
Cory