.net后台获取html控件值的2种方法
程序员文章站
2023-12-13 21:15:28
方法1: c# label1.text = request.form["txtname"].tostring(); vb.net request.form("txt...
方法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下调试通过