473,396 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="changepassword.aspx.cs" Inherits="changepassword" %>
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4.  
  5. <html xmlns="http://www.w3.org/1999/xhtml">
  6. <head runat="server">
  7.    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  8. <title>ABC Ltd. - change password</title>
  9. <script type="text/javascript">//starting of java script
  10.  
  11. function validate()//funtion to validate field and password length
  12. {
  13.        if (document.getElementById("name").value=="")
  14.       {
  15.                  alert("You must enter Username!");
  16.                  document.getElementById("name").focus();
  17.                  return false;
  18.       }
  19.        if (document.getElementById("curnt_paswrd").value=="")
  20.       {
  21.                  alert("You must enter old Password!");
  22.                  document.getElementById("curnt_paswrd").focus();
  23.                  return false;
  24.       }
  25.  
  26.  
  27.  
  28.       if (document.getElementById("new_paswrd").value=="")
  29.       {
  30.                  alert("New Password Field can not be blank!");
  31.                  document.getElementById("new_paswrd").focus();
  32.                  return false;
  33.       }
  34.         if(document.getElementById("con_frm_paswrd").value=="")
  35.       {
  36.                  alert("Confirm Password field can not be blank!");
  37.                 document.getElementById("con_frm_paswrd").focus();
  38.                 return false;
  39.       }
  40.  
  41.     if(document.getElementById("new_paswrd").value.length<6)
  42.     {
  43.      alert("Password should be at least six character long");
  44.      document.getElementById("new_paswrd").focus();
  45.      return false;
  46.      }
  47.      if((document.getElementById("new_paswrd").value)!=(document.getElementById("con_frm_paswrd").value))
  48.      {
  49.        alert("Confirm Password must match with the New Password")
  50.        document.getElementById("con_frm_paswrd").focus();
  51.        return false;
  52.        }
  53.        else
  54.        {
  55.          alert("You have successfully changed your old password")
  56.         }
  57. //function windowclose()
  58. //{
  59.  //window.close();
  60.  //}-->
  61.  
  62.  
  63.  
  64. }
  65. </script> 
  66. <link href="style.css" rel="stylesheet" type="text/css" />
  67. </head>
  68. <body>
  69. <div id="main_container"></div>
  70.   <!--header -->
  71.   <div id="header">
  72.     <h1 class="logo"><a href="#"><img src="Images/logo.gif" alt="funmobile-redifining mobile entertainment" title="funmobile-redifining mobile entertainment" /></a></h1>
  73.  
  74.   </div>
  75.   <!--header ends here-->
  76.   <div align="left">
  77.     <form id="form1" runat="server" action="">
  78.       <h3><span>Change Password</span></h3>
  79.       <fieldset>
  80.       <p>
  81.         <label for="User Name" style="margin:0 55px 0 0;" >User Name</label>
  82.         <asp:Textbox id ="name" runat="server" size="30" />
  83.       </p>
  84.       <p>
  85.         <label for="" >Current Password</label>
  86.         <asp:Textbox id="curnt_paswrd" textmode="Password" runat="server" size="30" />
  87.       </p>
  88.       <p>
  89.         <label for="" style="margin:0 30px 0 0;" >New Password</label>
  90.         <asp:Textbox id="new_paswrd" textmode="Password" runat="server" size="30" />
  91.       </p>
  92.       <p>
  93.         <label for="" >Confirm Password</label>
  94.         <input type="password" name="con_frm_paswrd" id="con_frm_paswrd" size="30" />
  95.       </p>
  96.       <p class="submit">
  97.         <asp:button ID="btnChange" class="submit-button" 
  98.               OnClientClick="return validate()" runat="server" Text="Change" 
  99.               onclick="btnChange_Click"/>
  100.       </p>
  101.       </fieldset>
  102.     </form>
  103.   </div>
  104.   <!--footer -->
  105.   <div id="footer">&copy; Funmobile. All Rights Reserved</div>
  106. </body>
  107. </html>
Sep 3 '10 #1
4 2659
Frinavale
9,735 Expert Mod 8TB
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
Sep 3 '10 #2
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
Sep 6 '10 #3
Frinavale
9,735 Expert Mod 8TB
You would open an ASPX page in the child window...so you would load the controls within that page.

-Frinny
Sep 7 '10 #4
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
Sep 7 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Daniel | last post by:
Is there a way to make a javascript do something when the user closes the browser? I would like it to go another url or something. I do not want this script to run when a user clicks on a link on...
8
by: Arun Seetharam | last post by:
Dear Folks, The application I am working on uses Frames (TopFrame, SideFrame(Left) and the MainFrame). On the occurance of a certain event, I am closing the window from one of the frames. This...
2
by: Kiran | last post by:
Hi all, Can anybody let me know how to detect when my user clicks the X button on the window. I used unload event it did not work(on IE). My web page is a .asp page which reloads itself when...
0
by: Bevo | last post by:
I validate my textbox input data on its Validating-event. But what if the textbox has focus when I click on the windows close button? Then I dont want to validate - at least not until I've confirmed...
6
by: Joe | last post by:
Hi, I have a form with Submit and cancel button. When Cancel button is clicked I want to close the browser window. Here is my sample form. To make things simple I have removed the submit button....
6
by: rakesh_nits | last post by:
Hi All, I want to close a directory which is being opened.what i have is only the path of the directory.How can i emulate clicking the close button on this window programmatically.Thanks in...
8
by: Sheldon Glickler | last post by:
Here is a problem I encounter often but haven't solved. In a form I have a submit button. When clicked, I want to do some processing so I check with the isset($_POST). (I keep all my code above...
1
by: srinivas | last post by:
Hi I'm having a asp.net page.When i'm clicking on the Logout hyperlink i want to close the window and clear the session. Actually i have taken LinkButton control and written a javascript function...
1
by: HeavyD | last post by:
I have a form with numerous textboxes and I use the validating event to validate these items. If I want to close that form with the X button in the upper right corner of that window validation may...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.