user3379303
user3379303

Reputation: 11

Open a Popup and redirect to another aspx page by same button click event in asp.net

I have a busienss requirement that, it needs to open a pop and also page redirection to be done in the same Submit button click event, presently i did both, but only Page redirection is happening, the popup is not working.

On commenting the Page redirection, the popup is working. Can anyone give me the solution for this? Eg.

Private Sub wbtnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) _
    Handles wbtnSubmit.Click
    wbtnSubmit.Attributes.Add("OnClick", "win_openPopUp();")
    ClientScript.RegisterStartupScript(Page.GetType(), "win_PopUp", "win_openPopUp();", True)

'Also i need this redirection also...'

If ViewState("Mode") <> "E" Then
    AppHelper.PageRedirect("2220", Localization.LocalizedLables.MessagesModules.MyMessages, AppHelper.PageMode.Add)
Else
    AppHelper.PageRedirect("2113", Localization.LocalizedLables.MessagesModules.MyMessages, AppHelper.PageMode.Add)
End If

End

In above code, any one is working... i need, after the pop close the page should be redirected to my specifed page.

Upvotes: 1

Views: 1467

Answers (1)

xavigonza
xavigonza

Reputation: 170

This line of code

ClientScript.RegisterStartupScript(Page.GetType(), "win_PopUp", "win_openPopUp();", True)

what does is to execute javascript win_openPopUp(); when it is reloaded the same page that did the postback . That's not what you want.

This line

wbtnSubmit.Attributes.Add("OnClick", "win_openPopUp();")

should be placed in page_load event, not here where the event has already been triggered. But you don't need to do that, as you can add this attribute in the button asp tag.

< asp:Button ID="wbtnSubmit" Text="" runat="server" OnClientClick="win_openPopUp();">

If you need more information about popups you can read

http://forums.asp.net/t/1283761.aspx?Response+Redirect+URL+and+target+_blank+

Upvotes: 1

Related Questions