[英]Why LinkButton inside repeater control load whole page? How to handle this issue in asp.net
我在這樣的asp.net項目的UpdatePanel內的中繼器控件中使用LinkButton
<asp:Repeater ID="rep_test" runat="server">
<HeaderTemplate>
<div class="form-group">
<br />
</HeaderTemplate>
<ItemTemplate>
<div class="col-sm-6">
<div class="form-group">
<asp:LinkButton runat="server" ID="itemid" >
<div id="ab-1" class="moder profile-tile-box">
<div class="itemname-box">
<asp:Label ID="lbltets" runat="server" Text='<%# Bind("itmName") %>'></asp:Label>
</div>
</div>
</asp:LinkButton>
</div>
</div>
</ItemTemplate>
<FooterTemplate>
</div>
</FooterTemplate>
</asp:Repeater>
這對我來說很好用,但是問題是當我單擊linkbutton時,它會刷新整個頁面並重新生成所有控件並關閉所有打開的Modal。 我該如何解決這個問題..請指導
檢查runat = server導致回發...在鏈接按鈕中嘗試OnClientClick =“ ... return false”
您必須將代碼包裝在更新面板中,以防止重新加載整個頁面
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true">
<ContentTemplate>
// add your repeater here
</ContentTemplate>
</asp:UpdatePanel>
這將對更新面板內部的那部分進行部分回發。 如果將模態放在模態內部,則它不會關閉模態本身,因為否則它將重建模態,從而導致將其關閉。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.