asp.net后台获取html控件值

注明:本文来自http://hi.baidu.com/technicalnotes/blog/item/69a92617027b0711962b435d.html

方法1:

C#

Label1.Text = Request.Form["txtName"].ToString();

vb.net

Request.Form("txtName").ToString()

方法2:

C#

System.Collections.Specialized.NameValueCollection nc = new System.Collections.Specialized.NameValueCollection(Request.Form);Label1.Text = nc.GetValues("txtName")[0].ToString();

: "txtName"为Html控件的"name"属性值

以上代码在Microsoft Visual Studio 2008下调试通过

原文地址:https://www.cnblogs.com/NetSos/p/1742176.html