Request.Form.Keys保存的是什么?

///1.这个Page_Load执行时Keys.Count为0,why?
/// 2.执行按钮事件,TextBox永远存在于Request.Form.Keys中
/// 3.CheckBox不管是服务器端控件还是Html控件,只在被选中时才包括在Keys中
/// 4.执行事件的那个Button也会包括在Request.Form.Keys中
/// 5.只要执行事件默认包括__VIEWSTATE与__EVENTVALIDATION
/// 博客园的高手谁能解释一下?我没有搜索到相关的信息,谢谢
单击Button1之后的效果:

<% @ Page Language = " C# "  AutoEventWireup = " true "  CodeFile = " FormKeys.aspx.cs "  Inherits = " test_FormKeys "   %>

<! 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 > Request.Form.Keys保存的是什么? </ title >
</ head >
< body >
    
< form  id ="form1"  runat ="server" >
    
< div >
        
< asp:Button  ID ="Button1"  runat ="server"  Text ="Button"  OnClick ="Button1_Click"   />
        
< asp:Button  ID ="Button2"  runat ="server"  Text ="Button"  OnClick ="Button2_Click"   />
        
< input  name ="chk1"  id ="chk1"  type ="checkbox"  runat ="server"   />
        
< asp:TextBox  ID ="TextBox1"  runat ="server" > hello </ asp:TextBox >
        
< asp:CheckBox  ID ="chk2"  runat ="server"  name ="chk2"   />
        
< input  id ="Submit1"  type ="submit"  value ="submit"  onclick ="form1.submit();"   />
    
</ div >
    
</ form >
</ body >
</ html >
using  System;
using  System.Data;
using  System.Configuration;
using  System.Collections;
using  System.Web;
using  System.Web.Security;
using  System.Web.UI;
using  System.Web.UI.WebControls;
using  System.Web.UI.WebControls.WebParts;
using  System.Web.UI.HtmlControls;
///   <summary>
///  1.这个Page_Load执行时Keys.Count为0,why?
///  2.执行按钮事件,TextBox永远存在于Request.Form.Keys中
///  3.CheckBox不管是服务器端控件还是Html控件,只在被选中时才包括在Keys中
///  4.执行事件的那个Button也会包括在Request.Form.Keys中
///  5.只要执行事件默认包括__VIEWSTATE与__EVENTVALIDATION
///  博客园的高手谁能解释一下?我没有搜索到相关的信息,谢谢
///   </summary>
public   partial   class  test_FormKeys : System.Web.UI.Page
{
    
protected   void  Page_Load( object  sender, EventArgs e)
    {
        
if  ( ! IsPostBack)
            Show();
    }
    
protected   void  Button1_Click( object  sender, EventArgs e)
    {
        Show();
    }
    
protected   void  Button2_Click( object  sender, EventArgs e)
    {
        Show();
    }
    
private   void  Show()
    {
        Response.Write(Request.Form.Keys.Count.ToString() 
+   " <br/> " );
        
for  ( int  i  =   0 ; i  <  Request.Form.Keys.Count; i ++ )
        {
            
string  ctl  =  Request.Form.GetKey(i);
            Response.Write(ctl 
+   " <br/> " );
        }
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值