ITPub博客

首页 > Linux操作系统 > Linux操作系统 > asp.net,网页层与div的数据交互

asp.net,网页层与div的数据交互

原创 Linux操作系统 作者:iDotNetSpace 时间:2008-09-28 13:43:27 0 删除 编辑

在我做的那个模块里涉及到div的相对位置的设置,网页层与div显示层之间数据的传递,之前我对div根本就不了解,经过这么一折腾啊,不得不明白了!好了,言归正传!

这是我的试验例子,有点乱,多多包含:

代码部分:

  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
  2. "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. "text/javascript" language="javascript"> 
  4.         function ShowNo()                        //隐藏两个层 
  5.         { 
  6.             document.getElementById("doing").style.display="none"; 
  7.             document.getElementById("divLogin").style.display="none"; 
  8.             getCheckValue();
  9.         } 
  10.         function $(id)        
  11.         { 
  12.             return (document.getElementById) ? document.getElementById(id) : document.all[id] ; 
  13.         } 
  14.         function showFloat(leftlocal)                    //根据屏幕的大小显示两个层 
  15.         { 
  16.             var range = getRange(); 
  17.         
  18.             $('doing').style.width = range.width + "px"; 
  19.             $('doing').style.height = range.height + "px"; 
  20.             $('doing').style.display = "block"; 
  21.             document.getElementById("divLogin").style.display=""; 
  22.             
  23.         } 
  24.         function getRange()                      //得到屏幕的大小 
  25.         { 
  26.               var top    = document.body.scrollTop; 
  27.               var left    = document.body.scrollLeft; 
  28.               var height  = document.body.clientHeight; 
  29.               var width  = document.body.clientWidth; 
  30.               if (top==0 && left==0 && height==0 && width==0) 
  31.               { 
  32.                 top    = document.documentElement.scrollTop; 
  33.                 left    = document.documentElement.scrollLeft; 
  34.                 height  = document.documentElement.clientHeight; 
  35.                 width  = document.documentElement.clientWidth; 
  36.               } 
  37.               return  {top:top  ,left:left ,height:height ,width:width } ; 
  38.         }
  39.         
  40.        function getCheckValue()
  41.        {
  42.             var theBox=document.all("divLogin")
  43.             var str=""
  44.             elm=theBox.getElementsByTagName('Input')
  45.             for(i=0;i
  46.             {
  47.                 if(elm[i].type=="checkbox")
  48.                 {
  49.              
  50.                     if (elm[i].checked==true)
  51.                     {
  52.                         //获得客户端checkbox的值
  53.                         str+=elm[i].nextSibling.innerText+",";
  54.                     }
  55.                 }
  56.             }
  57.           
  58.             document.getElementById("txtValue").value=str;
  59.              document.getElementById("Hidden1").value=str;
  60.               //document.write(document.getElementById("txtValue").value);
  61.        }
  62.     
  63. "http://www.w3.org/1999/xhtml">
  64. "server">
  65.     Div显示层
  66.     "form1" runat="server">
  67.   
  68.         
  69.         
  70.         
  71.         

  72.             "Hidden1" type="hidden" runat="server" />
  73.         

  74.         "txtBox" runat="server">
  75.         <!--"javascript.:void(0)" onclick="">登陆 //登陆链接-->
  76.         "Button1" runat="server" Text="Button" OnClick="Button1_Click"/>
  77.         "button" value="登陆" onclick="showFloat()" />
  78.         "txtValue" type="text" onfocus="showFloat()" />
  79.        
  80.            <!--加一个半透明层-->
  81.       "doing" style="filter: alpha(opacity=30); -moz-opacity: 0.3; opacity: 0.3;
  82.             background-color: Gray; width: 100%; height: 100%; z-index: 1000; position: absolute;
  83.             left: 0; top: 0; display: none; overflow: hidden;">
  84.         
  •         <!--加一个登录层-->
  •         "divLogin" style="background: #fff; padding: 10px 0 0 200px; width: 560px;
  •             z-index: 1001; position: relative; display: none; left: expression(document.getElementById('<%=this.txtBox.ClientID %>').offsetLeft+200+ 'px');
  •             ); top: expression(document.getElementById('<%=this.txtBox.ClientID%>').offsetTop+150+ 'px');
  •             margin: -200px 0 0 -400px; border-right: silver 1px solid; border-top: silver 1px solid;
  •             border-left: silver 1px solid; border-bottom: silver 1px solid;">
  •             "padding: 3px 15px 3px 15px; text-align: left; vertical-align: middle;">
  •                 
  •                     

  •                         请选择你要发送的对象
  •                     用户:
  •                     "TxtUserName" runat="server"> 
  •                 
  •                 
  •                     border-bottom-width: 1px; border-bottom-color: silver; border-top-color: silver;
  •                     border-right-width: 1px; border-right-color: silver;">
  •                     密码:
  •                     "TxtUserPwd" runat="server" TextMode="Password"> 
  •                 
  •                 
  •                 
  •                        
  •                     "BttLogin" runat="server" Text=" 登 陆 " /> 
  •                     "BttCancel" type="button" value=" 取 消 " onclick="ShowNo()" />
  •                 
  •                 "width: 100%">
  •                     "100%" border="1">
  •                         
  •                             "right">
  •                                 
  •                         
  •                         
  •                             
  •                                 "Panel1" runat="server" Direction="LeftToRight" ScrollBars="Auto" Width="100%"
  •                                     Height="90px" HorizontalAlign="Center">
  •                                     "CheckBoxList1" runat="server" RepeatColumns="8" Width="95%">
  •                                         "0">文件
  •                                         "2">数码
  •                                         "1">书本
  •                                         "3">电器
  •                                         "4">娱乐
  •                                         "5">军事
  •                                         "36">地球
  •                                         "89">环境
  •                                         "3">经济
  •                                         "3">政治
  •                                         "3">电器
  •                                         "3">娱乐
  •                                         "3">军事
  •                                         "3">地球
  •                                         "3">环境
  •                                         "3">经济
  •                                     
  •                                 
  •                                 
  •                             
  •                         
  •                     
  •                 
  •             
  •         
  •          
  •     
  • 来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/12639172/viewspace-466031/ ,如需转载,请注明出处,否则将追究法律责任。

    上一篇: c#.net常用函数和方法集
    下一篇: 反射
    请登录后发表评论 登录
    全部评论

    注册时间:2008-01-04

    最新文章