We help IT Professionals succeed at work.

Popup ASPX page wont stay modal up front

sbornstein2 asked
Medium Priority
Last Modified: 2008-03-17
Hello all.  I have a popup ASPX page that is called from a click even in my code behind button.  Problem is the main parent page is posting back and for some reason it keeps staying in front and my popup page is minimizing on the bottom.  Any idea what I can do?
Watch Question

Raju SrivatsavayeSoftware Engineer

did you use window.focus in your script

Do you SmartNavigation enabled?  If so, you'll need to turn it off or set it to false;


brdrok where do I turn that off I will try that?  sriv I placed that into an onblur in the body and it did not work.


I dont know if I want to mess with smartnavigation if it is by site because I am working as another developer on a project that already exists and dont want to mess with it too much.  It seems there is other popup pages that work fine and I looked through everything and mine is the same so it seems like the parent page I call it from might be in question.
When you look at the HTML part of your web pages, at the top you should see something like the following:

<%@ Page language="c#" Codebehind="AddUser.aspx.cs" AutoEventWireup="false" SmartNavigation=true Inherits="SomeNameSpace.admin.AddUser" %>

"I dont know if I want to mess with smartnavigation if it is by site... " 

It is not by site, it is by page.  Every HTML page should have this page declaration that you see above.  Not sure about placing it inside the "onblur" event of the body tag...I have a pop up calendar that I call like so:

btnCalendar.Attributes["onclick"]=@"javascript:calendar_window=window.open('Calendar.aspx?formname=Form1.txtDate', 'calendar_window', 'width=200, height=200'); calendar_window.focus(); calendar_window.moveTo(420, 285); calendar_window.focus();";

Just irgnore the queryString (?formanme=Form1.txtDate) part.  

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


Ok guys I found out the problem and maybe you can help me here.  I actually have this fixed but I am trying to also do one thing.  I found that in the parent page there is a setfocus to the first textbox control that was causing this.  It looks like this.

at top of page

      var setFocus =true;

bottom of page
      if (setFocus) {

so this was causing it.  I set it to false and it worked great.  So now I am trying to figure out is there a way to set the setFocus variable to false in the code behind easily?  I have worked around it by placing a set focus same way in the popup to my first control but I would rather leave that and still somehow set that setFocus in the parent to false.  Thanks again guys.


RegisterClientScriptBlock("nofocus", "<script>\nsetFocus = false;\n</script>\n");
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.