在UpdatePanel中动态加载UserControl

编程入门 行业动态 更新时间:2024-10-22 16:31:00
本文介绍了在UpdatePanel中动态加载UserControl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我在母版页上有一个菜单控件.单击任何菜单项时,我正在将用户控件加载到母版页的内容页(Default.aspx)上. 我使用了更新面板和一个占位符,在其中加载了用户控件. 问题是,每当我加载用户控件时,整个页面都会回发,而不是更新面板中的部分. 我应该如何在每次单击菜单项时实现部分回发而不是整个页面回发. Default.aspx

< asp:UpdatePanel runat = " 服务器" ID = " pnlSecurityMain" > < contenttemplate> < asp:PlaceHolder runat = " 服务器" ID = " plcDynamic" > </ contenttemplate >

代码隐藏

如果(!node.IsNull()) { UserControl uc =(UserControl)此 .LoadControl(node.UIControlId); uc.ID = " ucDynamicControl" ; plcDynamic.Controls.Add(uc); }

在此先感谢 Amit

解决方案

看看下面的链接. geekswithblogs/rashid/archive/2007/08/11/Loading-UserControl-Dynamically-in-UpdatePanel.aspx forums.asp/t/1085154.aspx 但是在用户控件中添加UpdatePanel并不容易. 将ASP.NET UpdatePanel控件与用户控件一起使用

Hi All, I have a menu control on master page. On clicking any of the menu items, I am loading a user control on content page(Default.aspx) of master page. I have used Update Panel and a Place holder inside on which i am loading the User Control. The issue is that whenever i load the User Control, Whole page postbacks instead of the part within Update Panel. How should i achieve partial postbacks on every menu item click instead of whole page postbacks. Default.aspx

<asp:UpdatePanel runat="server" ID="pnlSecurityMain"> <contenttemplate> <asp:PlaceHolder runat="server" ID="plcDynamic"> </contenttemplate>

Codebehind

if (!node.IsNull()) { UserControl uc = (UserControl)this.LoadControl(node.UIControlId); uc.ID = "ucDynamicControl"; plcDynamic.Controls.Add(uc); }

Thanks in Advance Amit

解决方案

Have a look at below links. geekswithblogs/rashid/archive/2007/08/11/Loading-UserControl-Dynamically-in-UpdatePanel.aspx forums.asp/t/1085154.aspx But is it not easier to have UpdatePanel in your User control. Using the ASP.NET UpdatePanel Control with User Controls

更多推荐

在UpdatePanel中动态加载UserControl

本文发布于:2023-11-11 18:10:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1579192.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加载   动态   UpdatePanel   UserControl

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!