![](/img/trans.png)
[英]Accessing html controls within an #include html file, from server side c#
[英]Get value from html side controls and pass it to server side controls
我對服務器端和html端控件有疑問。
這是我的代碼
ClientScript.RegisterStartupScript(this.GetType(),
"Enter Id",
" prompt('Enter your Id ....');",
true);
我想獲得用戶輸入的價值?
我該怎么辦?
試試這個
<form id="theform" runat="server">
<input type="hidden" id="hidValue" runat="server" />
</form>
從隱藏字段獲取價值的腳本
<script type="text/javascript">
function storeinput(id) {
document.getElementById("<%=hidValue.ClientID%>").value = id;
}
</script>
ClientScript.RegisterStartupScript(this.GetType(), "prompt", "var id = prompt('Enter your Id .'); storeinput(id);", true);
請嘗試以下:
請在ASPX頁面中定義隱藏變量:
<input type="hidden" id="hidValue" runat="server" />
請在CodeBehind下方編寫以下代碼:
ClientScript.RegisterStartupScript(this.GetType(), "prompt", "document.getElementById('" + hidValue.ClientID + "').value = prompt('Enter your Id .'); alert(document.getElementById('" + hidValue.ClientID + "').value); ", true);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.