在cs頁面獲取input的值方法
string username = 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" onclick="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>
這樣就可以實現在頁面中來搜尋內容了。呵呵