.net后台获取html控件值的2种方法
生活随笔
收集整理的這篇文章主要介紹了
.net后台获取html控件值的2种方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
方法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 2012下調試通過
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 2012下調試通過
總結
以上是生活随笔為你收集整理的.net后台获取html控件值的2种方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: (easyui datagrid+mvc
- 下一篇: asp.net夜话之五:Page类和回调