gdjlc

培养良好的习惯,每天一点一滴的进步,终将会有收获。

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

.ascx

 
<asp:TextBox ID="tbEntName" runat="server" Width="70px"></asp:TextBox>
<br />
<asp:TextBox ID="tbPassword" runat="server" Width="70px" TextMode="Password"></asp:TextBox>
.aspx
 
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="4.aspx.cs" Inherits="_4" %>
<%@ Register Src="EntLogin.ascx" TagName="EntLogin" TagPrefix="uc1" %>
<!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">
    <title>无标题页</title>
    <script type="text/javascript"> 
 function CheckData()
        {
          if(document.getElementById("<%=EntLogin1.FindControl("tbEntName").ClientID %>").value == "")
           {
              alert("名称不能为空!");
               return false;
            }  
           if(document.getElementById("<%=EntLogin1.FindControl("tbPassword").ClientID %>").value == "")
           {
              alert("密码不能为空!");
               return false;
            }           
          return true;    
        }
 </script>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <uc1:EntLogin ID="EntLogin1" runat="server" />
          <asp:Button ID="btnTest" runat="server" OnClientClick="return CheckData()" Text="测试" />
        </div>
       
    </form>
</body>
</html>
 
 
========================================
打开新窗口传值回原窗口
 
原窗口1.html:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function OpenNewDialog(){
    window.open('2.html','newwindow','width=400,height=300');
}
</script>
</head>
<body>
<input type="text" id="txt1" />
<input type="button" value="打开新窗口" onclick="OpenNewDialog()"/>
</body>
</html>
 
新窗口2.html:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function GetVal(){
    var txt1 = window.opener.document.getElementById('txt1');
    var txt2 = document.getElementById('txt2');
    txt1.value = txt2.value;
    window.close();
}
</script>
</head>
<body>
<input type="text" id="txt2" />
<input type="button" value="传值" onclick="GetVal()"/>
</body>
</html>
 
posted on 2008-10-07 12:53  gdjlc  阅读(607)  评论(0编辑  收藏  举报