jpsnow72
jpsnow72

Reputation: 995

Pop-Up with ASP.Net Button Click that is not blocked with popup blocker

I currently have an ASP.Net button click event that does a few things (including change session variables) prior to registering a new startup script As is, when a user clicks the button, their pop-up blocker blocks the popup even though it was technically triggered by a user event; I imagine the browser doesn't see it that way.

protected void ContinueButton_Click(object sender, EventArgs e)
{
    if (agreement.Checked)
    {
        string eid = Request.QueryString["eid"];
        Session["TestAgreement"] = "Agreed";
        openNewWindow("Exams/exam.aspx?id=" + courseCode, "height=760, width=1000, status=yes, toolbar=no, menubar=no, location=no, scrollbars=1");
    }          
}
private void openNewWindow(string url, string parameters)
{
    ClientScript.RegisterStartupScript(this.GetType(), "Exam", String.Format("<script>window.open('" + url + "', '', '" + parameters + "');</script>"));
}

Upvotes: 0

Views: 2958

Answers (2)

Crudler
Crudler

Reputation: 2286

AjaxControlToolkit's modal popup works nicely for this sort of thing.

http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/ModalPopup/ModalPopup.aspx

its still within the asp.net framework so you still get all your server side goodness, and you can always pop a usercontrol inside of it so that you can treat it as a separate "page"

just remember to keep your cclientidmode on your objects as static or predictable if you want to be able to hit them from your client side.

Upvotes: 2

Chris
Chris

Reputation: 1642

Do it with javascript. Do not open a new Window, just set a div in front and change its content.

The easiest would be, to use Jquery Dialog:

http://api.jqueryui.com/dialog/

Upvotes: 0

Related Questions