closing a pop up window

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tirthankar Dutta
    New Member
    • Sep 2010
    • 1

    #1

    closing a pop up window

    I am using this code.This pop up window pops up when I clicks a button on the main page.Now I want the pop up window to be closed if the password is successfully changed and reload the main page,but if the password is not changed then refresh the pop up window again.
    Here is the code.....

    Code:
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="changepassword.aspx.cs" Inherits="changepassword" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
       <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>ABC Ltd. - change password</title>
    <script type="text/javascript">//starting of java script
    
    function validate()//funtion to validate field and password length
    {
           if (document.getElementById("name").value=="")
          {
                     alert("You must enter Username!");
                     document.getElementById("name").focus();
                     return false;
          }
           if (document.getElementById("curnt_paswrd").value=="")
          {
                     alert("You must enter old Password!");
                     document.getElementById("curnt_paswrd").focus();
                     return false;
          }
         
          
          
          if (document.getElementById("new_paswrd").value=="")
          {
                     alert("New Password Field can not be blank!");
                     document.getElementById("new_paswrd").focus();
                     return false;
          }
            if(document.getElementById("con_frm_paswrd").value=="")
          {
                     alert("Confirm Password field can not be blank!");
                    document.getElementById("con_frm_paswrd").focus();
                    return false;
          }
     
        if(document.getElementById("new_paswrd").value.length<6)
        {
         alert("Password should be at least six character long");
         document.getElementById("new_paswrd").focus();
         return false;
         }
         if((document.getElementById("new_paswrd").value)!=(document.getElementById("con_frm_paswrd").value))
         {
           alert("Confirm Password must match with the New Password")
           document.getElementById("con_frm_paswrd").focus();
           return false;
           }
           else
           {
             alert("You have successfully changed your old password")
            }
    //function windowclose()
    //{
     //window.close();
     //}-->
    
    
    
    }
    </script> 
    <link href="style.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <div id="main_container"></div>
      <!--header -->
      <div id="header">
        <h1 class="logo"><a href="#"><img src="Images/logo.gif" alt="funmobile-redifining mobile entertainment" title="funmobile-redifining mobile entertainment" /></a></h1>
       
      </div>
      <!--header ends here-->
      <div align="left">
        <form id="form1" runat="server" action="">
          <h3><span>Change Password</span></h3>
          <fieldset>
          <p>
            <label for="User Name" style="margin:0 55px 0 0;" >User Name</label>
            <asp:Textbox id ="name" runat="server" size="30" />
          </p>
          <p>
            <label for="" >Current Password</label>
            <asp:Textbox id="curnt_paswrd" textmode="Password" runat="server" size="30" />
          </p>
          <p>
            <label for="" style="margin:0 30px 0 0;" >New Password</label>
            <asp:Textbox id="new_paswrd" textmode="Password" runat="server" size="30" />
          </p>
          <p>
            <label for="" >Confirm Password</label>
            <input type="password" name="con_frm_paswrd" id="con_frm_paswrd" size="30" />
          </p>
          <p class="submit">
            <asp:button ID="btnChange" class="submit-button" 
                  OnClientClick="return validate()" runat="server" Text="Change" 
                  onclick="btnChange_Click"/>
          </p>
          </fieldset>
        </form>
      </div>
      <!--footer -->
      <div id="footer">&copy; Funmobile. All Rights Reserved</div>
    </body>
    </html>
    Last edited by Frinavale; Sep 3 '10, 03:32 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Shouldn't you be doing sever side stuff for validating/changing passwords?

    Anyways, you can to use the window.opener property to get a reference to the parent window (the main page). You can use this reference to call a JavaScript method that exists in the parent window. This JavaScript method should call the JavaScript method that causes the ASP.NET page to post back to the server (the __doPostBack(.. .,...) method).

    So, after you have successfully authenticated the user, you would have your server side code write the JavaScript that uses the window.opener property to call the method to refresh the parent window, and then closes the window.

    -Frinny

    Comment

    • jagdeep gupta
      New Member
      • Aug 2010
      • 98

      #3
      how to use a new window

      how we can load controls in a child window on clicking event like login or change or forget password.
      and validation should also be done over there

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        You would open an ASPX page in the child window...so you would load the controls within that page.

        -Frinny

        Comment

        • jagdeep gupta
          New Member
          • Aug 2010
          • 98

          #5
          thanx for reply
          but how to load the controls as id of new page is not there (Actually i know just one method to open a new page i.e. taget="New" attribute)
          Please explain

          Comment

          Working...