PopUp Window from Codebehind

  • Thread starter Thread starter Rathtap
  • Start date Start date
R

Rathtap

I want to popup a window from my codebehind. The reason is that during
the postback the code needs to do some validations and to build the
arguments that are passed in the url. How can I achieve this
functionality?
The reason I do not want to use Response.Redirect is because when the
user comes back to the first page, all the selections that were
made(which are the arguments) disappear.
 
there is no way to do that directly from code-behind, it has to pass to a
clientside call
 
I saw Frank Gimberg do something similar to this in a demo once a year or
two ago. You can contact him at (e-mail address removed)
 
while you can emit javascript to do this, any popup blocker will stop it.

-- bruce (sqlwork.com)
 
You have a couple of options. One is to generate a JavaScript that opens the
new window. As has been pointed out, popup blockers will stop it. However,
another approach (also using JavaScript) is to programmatically click a
(hidden) hyperlink that opens in a new window, thus avoiding the popup
blockers. However, you wil have no control over the new window's size and
configuration.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
 
Forgive me. I spoke too quickly Upon reflection, I realized that JavaScript
can't click a hyperlink. Oh well. I can't think of any other way to open a
new browser window that won't be foiled by popup blockers. Best to try
another route.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
 
Kevin,

This has been bother me for quite awhile.

Why does my code for a pop-up window from my app not get blocked by IE SP2
pop-up blocker or the Google toolbar? (Yet some other pop-up blockers that
my users have installed does block it)

(No exceptions have been made in IE's Pop-up blocker settings either)

Private Function openNewWindow(ByVal url As String, ByVal windowName As
String, ByVal features As String) As String

' url parameter must be enclosed in single quotes!!!

Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder
sb.Append("javascript:var " & windowName & " = window.open(" + url +
",'" + windowName + "','" & features + "');" & windowName & ".focus();")

Return sb.ToString()
End Function

The code is not really important here. I think I might be missing the big
picture; are pop-up allowed if they are user initiated. (i.e. a user click a
hyperlink that causes the pop-up)?

BTW, here is a great link I saw yesterday to encapsulate creating a pop-up
into a class:

http://www.dotnet2themax.com/ShowContent.aspx?ID=5f606582-4626-4c6f-a6e9-6f952f31491a

Greg
 
It's not a popup if the user clicked it, it's a link. Popups are usually
designated as loaded from within the page without the user instructing it to
do so.
 
I don't think I expressed myself well.

For example, I have button (being a hyperlink button or push button) in a
datagrid. When the user selects it, is causes a postback. In the post back
code, I am building js window.open function that I append to the output of
the page with Page.RegisterStartupScript. (I am dynamically building the
querystring). How does/should a pop-up blocker treat this situation? My
pop-up blockers are allowing it, some or not.

Greg
 
Back
Top