We help IT Professionals succeed at work.

Popup ASPX page wont stay modal up front

sbornstein2
sbornstein2 asked
on
Medium Priority
476 Views
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?
Comment
Watch Question

Raju SrivatsavayeSoftware Engineer

Commented:
did you use window.focus in your script

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

Author

Commented:
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.

Author

Commented:
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.
Commented:
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

Author

Commented:
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.

PARENT PAGE:
at top of page

<script>
      var setFocus =true;
</script>

bottom of page
<script>
      if (setFocus) {
      document.getElementById("login_user").focus();
      }
</script>

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.

Author

Commented:
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.

OR

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.