VBnet on button_click need to run codebehind function then open modal dialog

76 Views Asked by At

I have an application where gridview data is selected and when finished, the user clicks a button to proceed. At that point I need to run a function in codebehind to process the selected items. Once completed, I then need to open a modal window to display the processed data and continue. My problem is that I cannot get the two things to occur from a single button click. The button onclick event fires the codebehind fine, but I cannot then get the modal to open. I can do a redirect but I want the modal. To open the modal, the ModalPopupExtender expects a separate button to be pressed. I have a javascript function to force a click of that button. Problem then becomes how to fire that script after running the codebehind. Help would obviously be appreciated! Thanks.

I've tried using the register script but that doesn't seem to execute it.

1

There are 1 best solutions below

1
Michael Foster On BEST ANSWER

When you're done with your code behind and ready to open the popup, you can have that happen when control goes back to the client:

ScriptManager.RegisterStartupScript(Me, Me.GetType, "WindowsScript", "OpenModalDialogPage();", True)

Then you can use a Javascript script to open the window:

function OpenModalDialogPage() {
    window.open("ThisIsANewWindow.aspx", "TitleOfNewWindow", "width=800px,height=250px");
}

Note this sets the width and height; adjust as needed for your specific application.