asp.net – 如何让我的转发器的Itemcommand事件不进行整页回发?
发布时间:2020-12-16 07:28:50 所属栏目:asp.Net 来源:网络整理
导读:在我的用户控件中,我有以下标记: div id="pageEditsView" style="margin-left:540px" asp:UpdatePanel runat="server" Triggers asp:AsyncPostBackTrigger ControlID="PageEditList"/ /Triggers ContentTemplate asp:HiddenField runat="server" ID="Curren
在我的用户控件中,我有以下标记:
<div id="pageEditsView" style="margin-left:540px"> <asp:UpdatePanel runat="server"> <Triggers> <asp:AsyncPostBackTrigger ControlID="PageEditList"/> </Triggers> <ContentTemplate> <asp:HiddenField runat="server" ID="CurrentPageId"/> <asp:Label runat="server" ID="EditDisplayLabel" Visible="False">Edits tied to this page:</asp:Label> <br/> <ul> <asp:Repeater runat="server" ID="PageEditList" OnItemCommand="PageEditList_ItemCommand"> <ItemTemplate> <li> <%# ((PageEdit)Container.DataItem).CachedName %> (<asp:LinkButton ID="LinkButton1" runat="server" Text="remove" CommandName="remove" CommandArgument="<%# ((PageEdit)Container.DataItem).Id %>" />) </li> </ItemTemplate> </asp:Repeater> </ul> </ContentTemplate> </asp:UpdatePanel> </div> 每当我点击删除链接按钮时,它都会执行整页回发,而不仅仅是更新此控件的面板.我的母版页具有以下设置: <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True" /> 这个应用程序的其他部分(我继承了,并且写了这个的旧开发人员已经不在了)似乎可以进行部分页面更新.难道我做错了什么? 解决方法
尝试注册linkbutton
as async postback control,适当的地方是
ItemCreated 事件,它在每个(异步/完整)回发时触发:
protected void PageEditList_ItemCreated(Object Sender,RepeaterItemEventArgs e) { if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { ScriptManager scriptMan = ScriptManager.GetCurrent(this); LinkButton btn = e.Item.FindControl("LinkButton1") as LinkButton; if(btn != null) { btn.Click += LinkButton1_Click; scriptMan.RegisterAsyncPostBackControl(btn); } } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – 什么使Web应用程序成为触摸板友好的应用程序
- asp.net – App_Data文件夹中的图像未显示在浏览器中
- asp.net – 使用Web Api,SignalR,MVC和OWIN的Ninject
- asp.net – 通过ajax将jquery中的数组传递给c#webmethod
- asp.net – 从Web服务返回XElement
- asp.net-mvc – 如何在.NET Web API项目中存储全局每个请求
- asp.net-mvc-3 – MVC3中的富文本区域
- asp.net-mvc-3 – EF 4.1上的MvcMiniProfiler代码优先项目不
- asp.net – ASP MVC使用超链接控制
- .NET 术语
推荐文章
站长推荐
- asp.net-mvc – 使用viewmodel时的asp.net mvc验
- asp.net-mvc – “添加控制器”/“添加视图”在混
- asp.net – 首先使用数据库向aspnetusers添加列
- asp.net – 存储库是否应该调用另一个存储库?或
- asp.net-mvc – 返回对象名称为MVC的Json Result
- asp.net-mvc – 如何在ASP.NET MVC路由中使用带有
- asp.net – 如何重命名Visual Studio 2012中的II
- asp.net-mvc – 使用MVC为iPhone应用构建RESTful
- asp.net – SCRIPT5022:Sys.WebForms.PageReque
- ASP.Net MVC 4窗体与2提交按钮/操作
热点阅读