我在 < 中有 Asp.net 文本框div> 点击btnReply"后的标签,<div> 由 Jquery Dialog 显示,因此用户在文本框中写下想法并单击发送"按钮(jquery 对话框按钮)并回发.
I have Asp.net text box in < div> tag which after click on "btnReply",< div> showes by Jquery Dialog, so user write idea at text box and click "Send" button (jquery dialog button) and post back happend.
但服务器端的 asp.net 文本框值为 null .为什么 ?我的代码在这里:
but the asp.net text box value at server side is null . Why ? my code is here :
<div id="ReplyDiv" style="display:none;">
<asp:TextBox ID="txtReply" runat="server" Textmode="MultiLine"/>
</div>
<input type="button" id="btnReply" onclick="javascript:retuen ShowReplyDialog();"/>
<asp:Button ID="AspBtnReply" runat="server" OnClick="AspBtnReply_Click" class="hidden"/>
/*-----Jquery script----*/
<script type="text/javascript">
function ShowReplyDialog()
{
$("#ReplyDiv").dialog({
width: 580,
buttons: {
"Close": function () { $(this).dialog("close");} ,
"Send" : function () {
//----Call Asp.net server method here
$("#<%=AspBtnReply.ClientID %>").click();
}
}
}).parent().appendTo($("form:first"));
}
</script>
经过大量搜索,我明白有一些原因:
After a lot of search i understand to have some reasons :
我可以解决它**Jquery UI Dialog 需要 z-index 样式**.我的意思是:
I can solved it **Jquery UI Dialog need z-index style ** . i mean :
<style>
.ui-widget-overlay
{
z-index:0;
}
</style>
并且需要jquery:
And need jquery :
$("#..").dialog(.....).parent().parent().appendTo($("form:first"));
我使用 UpdatePanel 已经有一段时间了,但我相信在部分回发时,它们只会发送更新后的控件值.因此,在 UpdatePanel 中移动 TextBox,或者使用 Javascript 在 UpdatePanel 中填充隐藏控件,并在更新时使用 TextBox 的上下文.item
It's been a while since I used UpdatePanels, but I believe that on partial postback they only send updated values for controls inside them. So move the TextBox inside the UpdatePanel, or perhaps use Javascript to populate a hidden control inside the UpdatePanel with the contexts of the TextBox whenever it is updated.item
要在后面的代码中获取输入的值并通过服务器控件机制(textBox.Text)访问它们,它们的状态(和存在)需要保存在 ViewState 中.由于您使用 javascript 构建它们,因此它们的状态不会持久化,获取它们的值的唯一方法是使用 Request.Form 集合.
To get the values of the inputs in the code behind and access them through the server controls mechanism (textBox.Text), their state (and presence) needs to be persisted in the ViewState. Since you are building them with javascript, their state is not persisted, the only way you can get their values is using the Request.Form collection.
这个问题说最好的提示:jQuery Dialog-Postback但是 UpdatePanel 没有得到更新**
This issue said best tips : jQuery Dialog-Postback but UpdatePanel doesn't get updated**
禁用控件是最好的问题:检索 asp:TextBox 的值
For disable controls is best issue : Retrieving the value of a asp:TextBox
这篇关于发生带有 Jquery 对话框的 post bock 时,asp.net 文本框值为 null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!