我有一个隐藏的字段
<asp:HiddenField ID="selectedRecievedValue" ClientIDMode="Static" runat="server" />
然后我有一个带有onfocus事件的TextBox
<asp:TextBox runat="server" Text='<%# Eval("value") %>' CssClass="rowSpildValue"
onfocus='<%# Eval("data_id", "document.getElementById(\"selectedDataID\").value =
\"{0}\"; document.getElementById(\"selectedFieldID\").value = \"rowSpildValue\";") %>'
OnTextChanged="SpildChanged" AutoPostBack="true" ID="rowSpildValue" />
这已经运行了一些代码,但是我如何添加另一行代码来设置我的
HiddenField = Eval("deliveredValue")
答案 0 :(得分:1)
答案 1 :(得分:1)
将JavaScript解压缩到JS函数
<script>
function onFocus(data_id) {
document.getElementById("selectedDataID").value = data_id;
document.getElementById("selectedFieldID").value = "rowSpildValue";
document.getElementById("selectedRecievedValue").value = <%# Eval("deliveredValue") %>;
}
</script>
然后将其设置为事件处理程序
<asp:TextBox runat="server" Text='<%# Eval("value") %>' CssClass="rowSpildValue"
onfocus='<%# Eval("data_id", "onFocus(\"{0}\");") .../>
答案 2 :(得分:1)
这将有效:
<asp:TextBox runat="server" Text='<%# Eval("value") %>' CssClass="rowSpildValue"
onfocus='<%# Eval(
"data_id",
"document.getElementById(\"selectedDataID\").value = \"{0}\";" +
"document.getElementById(\"selectedFieldID\").value = \"rowSpildValue\";") +
Eval(
"deliveredValue",
"document.getElementById(\"selectedRecievedValue\").value=\"{0}\"") %>'
OnTextChanged="SpildChanged" AutoPostBack="true" ID="rowSpildValue" />