![](/img/trans.png)
[英]How to set the value of a text box with javascript on an ASP.NET webform
[英]Cannot able to set text box value using javascript in ASP.NET
任何人都請告訴我如何設置文本框的值。
function moreFieldsEditFunction(ExtraFname, ExtraFvalue) {
document.getElementById('<%= TextBox1.ClientID %>').value =ExtraFvalue;
}
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
沒用
老實說,我不認為您要離開百萬富翁,我已經將您的代碼放入了帶有按鈕的Web窗體中,可以單擊該按鈕以調用該函數,並且該函數有效,而不會看到您的標記即可很難診斷,但看起來應該像這樣:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script type="text/javascript">
function moreFieldsEditFunction(ExtraFname, ExtraFvalue) {
document.getElementById('<%= TextBox1.ClientID %>').value = ExtraFvalue;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<input type="button" onclick="moreFieldsEditFunction('TEST', 'TEST2')" value="Click Me" />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</form>
</body>
</html>
這應該工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.