在Page_Init中动态添加每次加载的控件(如何避免每个控件重新加载?)
我正在添加 RadDock 控件并添加其项目命令事件,这些事件需要在 Pag_Init 中添加。并向 RadDock 添加用户控件。
我的问题是,当我对特定控件 page_Init 进行一些回发时,调用会重新加载控件,并且每次都会重新绑定每个控件。我想避免每次都创建控件。并希望特定控件的回发应该发生。
如果我在 Page_Init 中应用 (!IsPostBack)
条件,则不会加载控件并且页面变空。
我被困住了。
任何最佳实践或解决方法都是可以接受的。
提前致谢。
I am adding RadDock control and adding its Item Command events which require to be added in Pag_Init. And adding user controls to RadDock.
My problem is that when I have some post back for a specific control page_Init calls which reloads the controls and every control is re-binded every time. I want to avoid control creation every time. And want the specific control's post back should happen.
If I apply (!IsPostBack)
condition in Page_Init then controls are not loaded and page gets empty.
I am stuck.
Any best practice or work around is acceptable.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道 Telerik 工具的具体情况,但如果它们像常规 ASP.NET 动态控件一样工作,则必须在每次页面加载时将控件添加到控件树中。用数据填充控件与将它们添加到控件树不同。如果正确添加控件,以便它们以与上一个页面访问相同的方式放置在控件树中,并正确实现 ViewState(如果需要),则运行时将在回发时使用已发布数据和 ViewState 中的数据填充它们发生。
I don't know the specifics of Telerik's tools, but if they work like regular ASP.NET dynamic controls, you have to add the controls to the control tree on every page load. Populating the controls with data is distinct from adding them to the control tree. If the controls are added correctly so that they are placed in the same way in the control tree as on the previous page visit, and implement ViewState correctly (if needed) the runtime will populate them with data from the posted data and ViewState when a postback occurs.
我将 IFrame 添加到 RadDock,然后将用户控件源提供给 IFrame。现在工作正常,只有特定控件的回发发生。
无论如何,谢谢乔纳斯
I added IFrame to RadDock and then gave user control source to IFrame. Now it is working fine, Only the specific control's post back occurs.
Any way, Thanks Jonas