asp.net 獲取表單中控件的值

原文:https://blog.csdn.net/happymagic/article/details/8480235
 
C# 後臺獲取前臺 input 文本框值.(都是以控件的Name來獲取)
string aa=Request.Form[headself];

那麼要是後臺給前臺input文本框賦值呢?
後臺 public string Headself=null;
Headself="123";
前臺
<%=Headself%>
 
也能夠把input改成服務器控件,
<intpu type='textbox' runat='server'>
另外一種用ajax 取值,用javascirpt給客戶端控件input賦值 
例一:純客戶端控件<input name="edisundong" type="text">
在服務器端取得的方法string strvalue=Request.Form.Get("edisundong");
例二:純客戶端控件<input type="radio" name="sex" value="1" checked="true" /> <input type="radio" name="sex" value="2" /> string[] strvlaues=Request.Form.GetValues("sex");
相關文章
相關標籤/搜索