0

I have a button on my .aspx interstitial page. When I click it the onClick event fires off and it does a bunch of validations in the code. I have a javascript function that I need to call/run AFTER these validations are performed. This javascript function closes the interstitial page. How can I call the javascript function from my C# code? I've tried adding a script manager and a client script but neither work. What else besides these two options do I have? I'd be willing to use a hack if it works. Javascript I'm using:

javascript:parent.interstitialBox.closeit(); return false

1 Answer 1

1

On your button click you need to registerstartupscript..

protected void Button1_Click(object sender, EventArgs e)  
{  
    //Your validation
    string scriptclose = "parent.interstitialBox.closeit(); return false;";  
    ScriptManager.RegisterStartupScript(this, this.GetType(), "closeScript", scriptclose, true);  
}
Sign up to request clarification or add additional context in comments.

5 Comments

Thanks, I tried that and it just blinks at me. I know the JavaScript works because I have a "close" text link on my page tied to the Javascript function as well and that works.
Yes. The entire interstitial page blinks like it tried to do something but nothing happened.
I'm unable to get put it on my page without error. It gives me a "error creating control" every time I try to put it on my form. That's why I was wondering if there was another way to do this besides using the scriptmanager.
This is the recommended way, I believe you can also place a literal control on your page and set the value to the script text.
I'll keep working on trying to get the scriptmanager to work. Thanks for your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.