Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading