Saturday, March 24, 2012

call Function after modalPopup

I need some advice on how to call functions after a modalPopup is shown.

I am using the modalpopup1.show() method to show the popup window. However, the prolem I am having is the popup is not visible until it reaches the end of the routine.

example: The Button1.Click event calls the modalpopup1.show() method:

Private Sub Button1_Click(ByVal Sender... etc... .etc...)
DoSomeThings()

modalPopup1.Show() -- a textbox is filled based on what the user selects from the modalPopup Window, and that value is sent to a function

DoSomeMoreThings(textBox.text)

Sub

The problem is that the DoSomeMoreThings(string) function is called before the ModalPopup window appears, so when the DoSomeMOreThings() Function is called, the textbox is empty (The textbox is filled by the value selected by the user in the modalpopup)

How i get the popupt to show, get the value and then continue?

Thanks

Not sure if this will help you or not, but you can use JavaScript's setTimeout(...) to delay the call to "DoSomeMoreThings"

-Damien


Hi,

Put a button 'Continue' in your modal popup. Let user hit this button after he complete input for textBox.text. Then in OnClick event of 'Continue' button call your function.


Maybe I mis-understand, but I don't think so because I need the modalPopup to pop, get the user selection and then procede to the DoSomeMoreThings.

One think I thought of was to call the function from the client. But i'm not sure how to call a function in the code behind page from the client. Is this possible?


Just to clarify: The application does not stop at the modalPopup.show() method and wait for a response.

So, lets say i've got three button in the ModalPopup window: Button1, Button2, Button3.

If you click Button1, then, back in the main page, the textbox fills with Button1. Etc... for Button2, Button3.

Then, a function is called to set the text of a label to what you selected:

ModalPopup.Show()

GetLabelText(TextBox1.text)

Sub GetlabelText(ByVal str as String)
label1.text = "You Selected " & Str
End Sub

What is happening is when I run it, and say, click button 1, the page displays Button1 in the textbox, and the Label says "You Selected ". How can I make it wait after the modalPopup.Show() until the user makes a selection, before continuing on to GetLabelText()?


I'm sorry, but I really don't understand what you are trying to do. Can't you just call ModalPopup.Show() on the onchange or onblur of the TextBox?

-Damien


Or do it as Viktar suggested, call GetLabelText method in the onclick event handler of Button1, 2, 3.


I've run into this, and worked around it, by putting the content of the modal popup inside an updatepanel, and forcing a .Update() on it before you DoSomeMoreThings(textbox.text).. That way, you will get the new textbox value.

No comments:

Post a Comment