[英]PostingBack from ModalPopup, but keeping it visible?
我有一个ModalPopup,它将包含一个gridview和4个字段,用于将项目输入gridview本身。
是否可以在保持模态打开的同时回发到服务器并更新gridview?
当你提交字段并且回发发生时,模态关闭有没有人在此之前完成此操作? 有人提到使用jQuery的解决方案,但这很久以前。
在UpdatePanel中包装弹出窗口的内容(即不是弹出窗口本身!)对我有用。
我的弹出内容是一个带有可排序/可分页结果网格的搜索面板。 UpdatePanel给了我我需要的确切行为,没有额外的代码。
感谢Patel Shailesh的想法。
<asp:Panel runat="server" ID="PopupPanel" Height="650" Width="900" Style="display: none">
<asp:UpdatePanel runat="server" ID="UpdatePanel1">
<ContentTemplate>
<!-- popup content -->
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
<ajax:ModalPopupExtender runat="server" ID="PopupExtender" PopupControlID="PopupPanel"
TargetControlID="PopupButton" />
<asp:Button runat="server" ID="PopupButton" Text="Popup" />
这样做的关键是使用某种风格的AJAX - Microsoft.Ajax或jQuery Ajax。 如果UpdatePanel不起作用,那么我建议使用jQuery使用AJAX提交回服务器。 这将涉及创建WebMethod以接受服务器端的AJAX帖子,并使用jQuery检测客户端以发送请求/接收响应。 如果没有看到你的HTML,那就很难具体了。
基本理念:
$(function() {
$('#modalSubmitButton').click( function() {
$.ajax({
url: 'path-to-your-web-method',
dataType: 'json', // or html, xml, ...
data: function() {
var values = {};
values['field1'] = $('#field1ID').val();
...
values['field4'] = $('#field4ID').val();
return values;
},
success: function(data,status) {
... update page based on returned information...
}
... error handling, etc. ...
});
return false; // stop any default action from the button clicked
});
});
我不确定这是否可行,但尝试将modalpopup中的任何内容放在UpdatePanel中
如果这个作品在发布后不讨厌我,我也讨厌updatepanels
一种丑陋的选择是在首先显示模态弹出窗口并设置ViewState [“ModelPopupOn”] = true时强制回发; 然后在关闭弹出窗口时检查页面加载并最终再次回发并将其设置为false /从viewstate中删除它。
(这些问题是我讨厌ajax工具包的原因)
我正在尝试使用modalpopupextender,并找到一个丑陋的解决方案。 如果模态面板有一个按钮,使回发发生
<asp:Panel runat="server" ID="PopupPanel" Height="650" Width="900" Style="display: none">
<asp:Button ID="OkButton" runat="server" Text="OK" OnClick="OkBtn_Click" />
</asp:Panel>
如果代码隐藏中的OkBtn_Click有一个调用:
System.Web.HttpContext.Current.Response.Write("<script></script>");
然后modalpopupextender没有关闭。 对于这个家伙来说也是如此: http : //forums.asp.net/t/1591860.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.