在cs后台页面获取input的值方法

概述:

想在后台cs页面得到前台页面aspx中html控件input输入的值.

解决方法如下:

1.用Request["name"].toString();.

前台代码如下:

用户名:<inputname="username"type="text">

后台获取代码如下(记住:一定要是name的值,不是id的值):


string username = Request[ " username " ].ToString();

2.用Request.Form.Get("name").ToString();

前台代码如上一样.

后台获取代码如下:


stringusername=Request.Form.Get("username").ToString();

3.用Request["name"];

前台代码如上一样。

后台获取代码如下:

code

string usrname=Request["name"];

注:在前台获取html的值:

方法:document.all.("你的控件的id").value;

例如:下面实现了在页面中搜索的功能

<input id="t1" type="text" />

<input id="Button1" οnclick="findInPage(document.all.t1.value)"
type="button" value="button" />

<script language="javascript">
var NS4 = (document.layers);var IE4 = (document.all);var win = window;var n = 0;
function findInPage(str){
var txt, i, found;
if (str == '') return false;
if (NS4){
if (!win.find(str))
while(win.find(str, false, true))
n++;
else
n++;
if (n == 0)
alert('Not found.');}
if (IE4){
txt = win.document.body.createTextRange();
for (i = 0; i <= n && (found = txt.findText(str)) != false; i++){
txt.moveStart('character', 1);
txt.moveEnd('textedit');}
if (found){
txt.moveStart('character', -1);
txt.findText(str);
txt.select();
txt.scrollIntoView();
n++;}else{if (n > 0){
n = 0;
findInPage(str);}else alert('没有符合查询条件的数据!');}}return false;}
</script>

这样就可以实现在页面中来搜索内容了。呵呵

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值