asp.net - Creating Radwindow in code behind and avoiding postback on radwindow close
问题描述
I can create a radwindow on the server side. Here is the code being executed on button click. The close button is created in the code behind too.
protected void OpenRW_Click(object sender, System.EventArgs e)
{
RadWindow window = new RadWindow();
window.Modal = true;
window.EnableViewState = false;
window.VisibleOnPageLoad = true;
window.Width = 300;
window.Height = 300;
window.VisibleOnPageLoad = true;
window.Visible = true;
window.DestroyOnClose = true;
window.Behaviors = Telerik.Web.UI.WindowBehaviors.Move;
window.ID = "Popup";
//create close button here
Button closebt = new Button();
closebt.Visible = true;
closebt.Text = "Close";
closebt.OnClientClick = "$find(\" <%= Popup.ClientID %> \").close(); return false;";
closebt.Style.Add("position", "absolute");
closebt.Style.Add("bottom", "5px");
closebt.Style.Add("right", "10px");
window.ContentContainer.Controls.Add(closebt);
RadWindowManager1.Controls.Add(window);
}
But for some reason when it gets closed it fires a unneeded postback. I've tried a whole bunch of things including setting the viewonpageload property to false and using scriptmanager to display the window, but this yields the same results. Any ideas on how I can get rid of this unnecessary postback would be greatly appreciated. thanks in advance.
解决方案
The issue was with DNN (dotnetnuke) reassigning the clientid. The clientid was rendering differently so the js wasn't recognizing the clientid that was being preemptively loaded on the postback which was throwing an exception in the browser and thus causing the extra postback on the window close. My work around was to use jquery to hide the div of the window by using the window class as an identifier and then remove the the modal overlay.
closebt.OnClientClick += "$('.<yourwindowclass>').hide();$telerik.$(\".TelerikModalOverlay\").remove(); return false;";
I also interfaced with the telerik team on this issue. I should add their support is very good.
https://www.telerik.com/forums/creating-radwindow-on-server-side#FAxVzO4lYkC7jHDx21chOw
推荐阅读
- reactjs - 在 react.js 中,addToCartHandler 更新了购物车,但无法立即在页面上呈现更新后的属性,而是等待一次重新呈现
- excel - SSRS 2014 导出到 Excel、Word 文件时出错,但 PDF、CSV 没有错误
- javascript - 如何在 React js 中将一个步进器状态值接收到另一个步进器
- python - 如何从设备网络服务器进行网络抓取
- mapbox - 在 MapBox 中找不到其他语言的标签时,如何将标签默认为英语?
- django - allauth url 不可访问 - 404 错误
- r - 加速 R 中的 tapply 函数,或其他将数据帧转换为矩阵的函数
- java - 如何在 java 12 中启用增强型开关语句的执行?
- c++ - 当使用 gdbus emit 发出信号时,Gio::DBus 的子类不会调用 on_signal()
- node.js - Node.js/Express 发布路由失败