Jquery UI 模式对话框问题与更新面板按钮触发器
我面临一个愚蠢的问题,但很难解决。
我在更新面板中有一个复选框控件。
<asp:UpdatePanel ID="UpdateCheckEdit" runat="server"><ContentTemplate>
<asp:CheckBox ID="ChkEdit" Text="Edit" Enabled="true" onCheckedChanged="ChkEdit_CheckedChanged" Visible="false" AutoPostBack="true" runat="server" />
<asp:TextBox ID="txtDbInterviewComments" CssClass="user_textarea" TextMode="MultiLine" Visible="false" runat="server" />
<asp:Button ID="btnEdit" Visible="false" CssClass="create_btn" OnClientClick="javascript: $('#ConfirmDiv').dialog('open');return false;" OnClick="btnEdit_Click" Text="Edit" runat="server" />
</ContentTemplate></asp:UpdatePanel>
在检查更改时,文本框和编辑按钮都可见,一旦点击编辑按钮,就会弹出一个模式对话框,要求确认该框的 div 如下所示。
<div id="ConfirmDiv" title="Confirm">
<p><span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>Do you want to save the changes?<br />These changes CANT be reversed.</p>
</div>
Jquery 的脚本编写为此
<script type="text/javascript">
$().ready(function () {
$("#ConfirmDiv").dialog(
{ autoOpen: false,
modal: true,
bgiframe: true,
resizable: false,
height: 'auto',
open: function (event, ui) { jQuery('.ui-dialog-titlebar-close').hide();},
buttons: {'Yes': function () { <%=this.Page.ClientScript.GetPostBackEventReference(new PostBackOptions(this.btnEdit))%>; },'Cancel': function () { $(this).dialog('close'); }}
})
});
</script>
脚本编写在 BODY 标记中,单击“是”按钮会调用“编辑”按钮(btnEdit)的回发事件 在后面
的代码中,一切运行正常,但是执行后模态框仍然显示 向上。我需要在代码执行后关闭此对话框。
如果我删除更新面板,一切都工作得很好,但同一页面上的网格视图中存在一个 HTML 单选按钮列,如果发生完整回发,该列将失去检查。 .
请帮我提供可能的解决方案..
I am facing a silly issue but struggling hard to resolve..
I have a Checkbox control in update panel..
<asp:UpdatePanel ID="UpdateCheckEdit" runat="server"><ContentTemplate>
<asp:CheckBox ID="ChkEdit" Text="Edit" Enabled="true" onCheckedChanged="ChkEdit_CheckedChanged" Visible="false" AutoPostBack="true" runat="server" />
<asp:TextBox ID="txtDbInterviewComments" CssClass="user_textarea" TextMode="MultiLine" Visible="false" runat="server" />
<asp:Button ID="btnEdit" Visible="false" CssClass="create_btn" OnClientClick="javascript: $('#ConfirmDiv').dialog('open');return false;" OnClick="btnEdit_Click" Text="Edit" runat="server" />
</ContentTemplate></asp:UpdatePanel>
On check change the textbox and edit button both are visible and once the edit button is hit a modal dialog pops up asking for a confirmation and the div for the box is as follows..
<div id="ConfirmDiv" title="Confirm">
<p><span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>Do you want to save the changes?<br />These changes CANT be reversed.</p>
</div>
The script for the Jquery is written as
<script type="text/javascript">
$().ready(function () {
$("#ConfirmDiv").dialog(
{ autoOpen: false,
modal: true,
bgiframe: true,
resizable: false,
height: 'auto',
open: function (event, ui) { jQuery('.ui-dialog-titlebar-close').hide();},
buttons: {'Yes': function () { <%=this.Page.ClientScript.GetPostBackEventReference(new PostBackOptions(this.btnEdit))%>; },'Cancel': function () { $(this).dialog('close'); }}
})
});
</script>
This script is written in BODY tag and the Yes button click calls the post back event of Edit button(btnEdit)
In the code behind everything runs fine but after execution the modal box still shows up. I need to close this dialog box after code behind execution..
If i remove the update panel, everything works absolutely fine but there exists a HTML radio button column in grid view on the same page which looses its check if a full post back occurs..
Please help me out with possible solutions..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您将面临的主要问题是 document.ready 不会在部分回发时触发。要解决此问题,您可以在名为 PageLoad 的 javascript 函数中更新 jquery 对象:
我相信它区分大小写。
the main problem you will face is that document.ready is not fired on a partial postback. To work around this issue you can update your jquery object in a javascript function called PageLoad:
I believe it is case sensitive.
看,更新面板将清除页面内的所有 jQuery 代码。尝试使用
PageRequestManager
。See, the update panel will wipe out all the jQuery code inside the page. Try to use the
PageRequestManager
.