页面之间传递值方式1: ......
页面之间传递值
方式1:
    
在接收页 的html代码里加上一行: <%@ Reference Page = "WebForm1.aspx" %>            
     
    WebForm1 fp=(WebForm1)Context.Handler;
    this.TextBox1.Text=fp.name;   //name 是第一页的public变量


Context  提供对整个当前上下文(包括请求对象)的访问。您可以使用此类共享页之间的信息。 

方式2:GET方式
    在发送页
      public int sum=0;

           int i =int.Parse(this.TextBox1.Text)*2;

           Server.Transfer("WebForm2.aspx?sum="+i);

    接收页
        this.TextBox1.Text=Request["sum"].ToString();
    or  this.TextBox1.Text=Request.Params["sum"].ToString();
        this.TextBox1.Text=Request.QueryString["sum"];


方法3:全局变量

   发送页:
       Application["sum"]=this.TextBox1.Text;
       Server.Transfer("WebForm2.aspx");

   接收页:
       this.TextBox1.Text=(string)Application["sum"];

Application实质上是整个虚拟目录中所有文件的集合,如果想在整个应用范围内使用某个变量值,Application对象将是最佳的选择



方法4:

 发送页:
    1.定义静态变量:  public static string str=""
    2. str=this.TextBox1.Text;
       Server.Transfer("webform2.aspx");
 接收页:
    1.引入第一页的命名空间:using WebApplication1;
    2  this.TextBox1.Text=WebForm1.str;


鼠标菜单制作
<html>
<head>
</head>
<body>
<STYLE>.skin0  { 
BORDER-RIGHT:  black  1px  solid;  BORDER-TOP:  black  1px  solid;  VISIBILITY:  hidden;  BORDER-LEFT:  black  1px  solid;  WIDTH:  150px;  CURSOR:  default;  LINE-HEIGHT:  1px;  BORDER-BOTTOM:  black  1px  solid;  FONT-FAMILY:  Verdana;  POSITION:  absolute;  BACKGROUND-COLOR:  black;  TEXT-ALIGN:  left 

.skin1  { 
BORDER-RIGHT:  buttonhighlight  0px  outset;  BORDER-TOP:  buttonhighlight  0px  outset;  FONT-SIZE:  9pt;  VISIBILITY:  hidden;  BORDER-LEFT:  buttonhighlight  0px  outset;  WIDTH:  120px;  CURSOR:  default;  BORDER-BOTTOM:  buttonhighlight  0px  outset;  FONT-FAMILY:  Arial,  Helvetica,  sans-serif;  POSITION:  absolute;  BACKGROUND-COLOR:  #000000;  TEXT-ALIGN:  center 

.menuitems  { 
PADDING-RIGHT:  10px;  PADDING-LEFT:  10px 

</STYLE> 
<SCRIPT  language=JavaScript> 

<!--  Begin 
var  menuskin  =  "skin1"  //  skin0,  or  skin1 
var  display_url  =  0;  //  Show  URLs  in  status  bar? 
function  showmenuie5()  { 
var  rightedge  =  document.body.clientWidth-event.clientX; 
var  bottomedge  =  document.body.clientHeight-event.clientY; 
if  (rightedge  <  ie5menu.offsetWidth) 
ie5menu.style.left  =  document.body.scrollLeft  +  event.clientX  -  ie5menu.offsetWidth; 
else 
ie5menu.style.left  =  document.body.scrollLeft  +  event.clientX; 
if  (bottomedge  <  ie5menu.offsetHeight) 
ie5menu.style.top  =  document.body.scrollTop  +  event.clientY  -  ie5menu.offsetHeight; 
else 
ie5menu.style.top  =  document.body.scrollTop  +  event.clientY; 
ie5menu.style.visibility  =  "visible" 
return  false; 

function  hidemenuie5()  { 
ie5menu.style.visibility  =  "hidden" 

function  highlightie5()  { 
if  (event.srcElement.className  ==  "menuitems")  { 
event.srcElement.style.backgroundColor  =  "highlight" 
event.srcElement.style.color  =  "white" 
if  (display_url) 
window.status  =  event.srcElement.url; 
      } 

function  lowlightie5()  { 
if  (event.srcElement.className  ==  "menuitems")  { 
event.srcElement.style.backgroundColor  =  "" 
event.srcElement.style.color  =  "black" 
window.status  =  "" 
      } 

function  jumptoie5()  { 
if  (event.srcElement.className  ==  "menuitems")  { 
if  (event.srcElement.getAttribute("target")  !=  null) 
window.open(event.srcElement.url,  event.srcElement.getAttribute("target")); 
else 
window.location  =  event.srcElement.url; 
      } 

//    End  --> 
</SCRIPT> 

<DIV  class=skin0  id=ie5menu  onmouseover=highlightie5()   
style="LEFT:  280px;  TOP:  28px"  onclick=jumptoie5();  onmouseout=lowlightie5()> 
<DIV> 
<TABLE  height="97%"  cellSpacing=1  cellPadding=0  width="98%"  align=center   
bgColor=#000000> 
    <TBODY> 
    <TR> 
        <a  href="http://www.dqhc.com"  target=_blank><TD   
        onmouseover="this.style.backgroundColor=''#999900'';  this.style.cursor=''hand'';"   
        onmouseout="this.style.backgroundColor=''#99cc33'';"  bgColor=#99cc00  height=20   
        scroll="no"  onload="window.defaultStatus=''00009876.4567.net'';"> 
         
            <CENTER><BR>华创公司<br><br></CENTER></TD></a></TR> 
    <TR> 
        <a  href="http://www.sina.com.cn"  target=_blank><TD   
        onmouseover="this.style.backgroundColor=''#ff9900'';  this.style.cursor=''hand'';"   
        onmouseout="this.style.backgroundColor=''#ffcc00'';"  bgColor=#ffcc00   
height=20> 
            <CENTER><br> 
            新浪首页
              <br><br></CENTER></TD></a></TR> 
    <TR> 
        <A  href="http://www.sohu.com"  target=_blank><TD   
        onmouseover="this.style.backgroundColor=''#ff6633'';  this.style.cursor=''hand'';"   
        onmouseout="this.style.backgroundColor=''#ff9900'';"  vAlign=center   
        bgColor=#ff9900> 
            <br><CENTER>搜狐首页 <br><br> 
            </CENTER></TD></A></TR> 
   
      <TR><A  
            href="http://www.163.com"> 
        <TD   
        onmouseover="this.style.backgroundColor=''#ff9900'';  this.style.cursor=''hand'';"   
        onmouseout="this.style.backgroundColor=''#ffcc00'';"  vAlign=center   
        bgColor=#ffcc00> 
            <br><CENTER>网易首页</CENTER><br></TD></A></TR> 
   
</TBODY></TABLE></DIV></DIV> 
<SCRIPT  language=JavaScript> 
if  (document.all  &&  window.print)  { 
ie5menu.className  =  menuskin; 
document.oncontextmenu  =  showmenuie5; 
document.body.onclick  =  hidemenuie5; 

</SCRIPT> 
</body>
</html
posted on 2004-06-20 13:43  奚彧  阅读(563)  评论(0)    收藏  举报