1.1 选择窗体的页面tvMenu.aspx

 <head id="Head1" runat="server">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
      <title>项目积累</title>
      <style type="text/css">
          span{
              width:111px;
              background-color:#f2f0f0;
              display:block;
          }
     </style>
     <script type="text/javascript">
         function reflash() {
             window.location.href = window.location.href;
         }
     </script>
     <script src="jquery-1.4.1.js" type="text/javascript"></script>
  
     <script type="text/javascript">

         $(function () {
             $("#btnSelect").click(function () {
                 window.open('WebForm1.aspx', 'newwindow', 'height=400, width=750, top=240, left=300, toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, status=no');
             });
             // 身份证号文本框失去焦点        
             $("#idCard").blur(function () {
                 // 获取身份证号
                 var userCard = $("#idCard").val();
                 if (userCard == "") {
                     // 输入为空,返回不计算
                     return;
                 }
                 //获取年龄
                 var nowDate = new Date();
                 var month = nowDate.getMonth() + 1;
                 var day = nowDate.getDate();
                 var age = nowDate.getFullYear() - userCard.substring(6, 10);
                 if (userCard.substring(10, 12) < month || userCard.substring(10, 12) == month && userCard.substring(12, 14) <= day) {
                     // 按我们平时所谓的"虚岁"计算
                     age++;
                 }
                 $("#age").val(age);
                 $("#age").attr('readonly', true);
             });
             // 值输入数字
             $("#age").keypress(function (event) {
                 var keyCode = event.which;
                 if (keyCode >= 48 && keyCode <= 57) {
                     return true;
                 }
                 else {
                     return false;
                 }
             }).focus(function () {
                 // return false,输入法关闭
                 this.style.imeMode = 'disabled';
             });
         })
     </script>
 </head>
 <body>
     <form id="form1" runat="server">
     <div>
         <span>姓 名</span>
    <input id="name" type="text" runat="server"/><input id="btnSelect" type="button" value="选择目录" />
     </div>
         <div>
             <span>身份证号码</span>
     <input id="idCard" type="text"/>
     </div>
          <div>
              <span>年龄</span>
     <input id="age" type="text"/>
     </div>
     </form>
</body>

 

1.2 后台

tvMenu.aspx.cs

  protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["MenuId"] != null)
                {
                    this.name.Value = Session["MenuId"].ToString();
                }
            }
        }

2.1 选择目录的前台 menu.aspx


<!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>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
<asp:treeview runat="server" ID="tvMenu" ImageSet="Simple"
            onselectednodechanged="tvMenu_SelectedNodeChanged" Width="266px">
    <HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" />
    <Nodes>
        <asp:TreeNode Text="管理员" Value="1001">
            <asp:TreeNode Text="销售总监-王小四" Value="100101">
                <asp:TreeNode Text="销售主管-李海洋" Value="10010101">
                    <asp:TreeNode Text="销售员-海里" Value="1001010101"></asp:TreeNode>
                    <asp:TreeNode Text="销售员-陈建平" Value="1001010102"></asp:TreeNode>
                    <asp:TreeNode Text="销售员-吕文静" Value="1001010103"></asp:TreeNode>
                </asp:TreeNode>
                <asp:TreeNode Text="销售主管-张强" Value="10010102">
                    <asp:TreeNode Text="销售员-李响" Value="1001010201"></asp:TreeNode>
                </asp:TreeNode>
            </asp:TreeNode>
        </asp:TreeNode>
    </Nodes>
    <NodeStyle Font-Names="Tahoma" Font-Size="10pt" ForeColor="Black"
        HorizontalPadding="0px" NodeSpacing="0px" VerticalPadding="0px" />
    <ParentNodeStyle Font-Bold="False" />
    <SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD"
        HorizontalPadding="0px" VerticalPadding="0px" />
        </asp:treeview>
    </div>
    </form>
</body>
</html>

 

2.2 选择目录的后台 menu.aspx.cs


        protected void Page_Load(object sender, EventArgs e)
        {
            loadDefault();
        }

        void loadDefault()
        {
            //加载目录树
        }

        protected void tvMenu_SelectedNodeChanged(object sender, EventArgs e)
        {
             Session["MenuId"]=string.Empty;
             if (this.tvMenu.SelectedNode.Value != null)
             {
                 Session["MenuId"] = this.tvMenu.SelectedValue;
             }

            Response.Write("<script>window.close();window.opener.reflash();window.opener=null;</script>");
            //前我做能脚本某写错需要测试
        }

posted on 2014-07-30 11:16  南湖居士  阅读(441)  评论(0)    收藏  举报