I have a page displaying post with comments and subcomments , each comment have a reply linkbutton when clicked it shows a textbox and a button to add subcomments, the problem is the linkbutton only works the 1st and 2nd time .... the third time nothing happnes i tried debugging it and i get nothing at all it didn't go to the server here is the code
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="addComment_btn" />
</Triggers>
<ContentTemplate>
<asp:Repeater ID="Repeater1" runat="server"
onitemdatabound="Repeater1_ItemDataBound"
onitemcommand="Repeater1_ItemCommand">
<ItemTemplate>
<ol class="cosmo-comment-list cosmo-comment-plain">
<li class="comment even thread-even depth-1" id="li-comment-2">
<div id="comment-2" class="comment-body">
<asp:HiddenField ID="commentID_hidden" runat="server"
Value='<%# Eval("comments_ID") %>' />
<div class="cosmo-comment-thumb"><img alt="" src="images/default_avatar.jpg" class="avatar avatar-60 photo" height="60" width="60"></div>
<div class="cosmo-comment-leftpointer"></div>
<div class="cosmo-comment-quote">
<div class="cosmo-comment-textinfo">
<span class="user"><%# Eval("commenter_name")%></span>
<span class="time"><%#Eval("comment_date")%> </span>
<span class="gray reply fr"><a class="comment-reply-link" href="#">
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:LinkButton ID="reply_linkbtn" runat="server" Visible="false" CommandName="reply">Reply</asp:LinkButton>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="reply_linkbtn" />
</Triggers>
</asp:UpdatePanel>
</a></span>
</div>
<p> <%# Eval("text") %> </p>
</div>
</div>
</li>
</ol>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="reply_linkbtn" />
</Triggers>
<ContentTemplate>
<asp:TextBox ID="subcomment_textbox" runat="server" Visible="false"></asp:TextBox>
<asp:Button ID="add_subcomment_btn"
runat="server" Text="Button" Visible="false"/>
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
Edit: Problem fixed it was in the code behind I don't know the actual reason but in the page load I always called the repeater.Databind() method and that caused the problem... when i made a condition if (!IsPostBack) and then bind the data the problem was fixed
Related
Below is the code.
Everything else is working fine. Just when the user clicks btnWhishlist (if user not logged-in) ModalPopupExtender displays for login. On popup whether Cancel or Login is clicked, even if the user gets logged in, the btnWishlist button disappears.
When the page is reloaded the button appears again. Looks like UseSubmitBehavior="false" is creating the problem. The page do not reload but only the button disappears, everything else remains same.
Tried jquery to show the panel/div that contains the button. No Luck.
<ContentTemplate >
<asp:ListView ID="usrListShowImages" runat="server" OnItemCommand="usrListShowImages_ItemCommand" OnItemCreated="usrListShowImages_ItemCreated" >
<LayoutTemplate>
some layout
</LayoutTemplate>
<ItemTemplate>
<tr>
<asp:UpdatePanel runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false" ID="up_inlv">
<ContentTemplate>
<div id="divWishlist" class="wishlist" runat="server">
<div class="<%--growuser--%>picUserShow">
<asp:ImageButton ID="btnImages" ImageUrl='<%# ".." + Eval("ItemsPicUrl") %>' runat="server" CssClass="growuser" CommandName="btnImages" CommandArgument='<%# Eval("ID") %>' />
<asp:Panel class="bottomDiv" runat="server" id="btmDiv"> <%-- HAVE USER SIGNIN, CHECK FROM DB THAT THIS ITEM WAS ADDED TO WISHLIST OR NOT AND THEN ALOT THE BUTTON TEXT ACCORDINGLY --%>
<asp:UpdatePanel runat="server">
<ContentTemplate>
<asp:Button ID="btnWhishlist" Text='<%# Eval("colbtnwishlist") %>' runat="server" CssClass="wishlistButton" CommandName="btnWhishlist" CommandArgument='<%# Eval("ID") %>' UseSubmitBehavior="false" EnableViewState="true" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
<div class="bottomDivCart">
<asp:UpdatePanel runat="server">
<ContentTemplate>
<asp:Button ID="btnCart" Text="Cart" runat="server" CssClass="CartButton" CommandName="btnCart" UseSubmitBehavior="false" CommandArgument='<%# Eval("ID") %>' EnableViewState="true" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div class="caption">
<%# Eval("captionforpage") %>
</div>
</div>
<div class="priceTag">Price Rs.<%# Eval("priceofarticle") %></div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</tr>
</ItemTemplate>
There are no errors so far. The wish button should show up without having a page reload, the same way the other artifacts are showing up
Is there way to update listbox in loop? I have an updatepanel with a listbox.
<asp:UpdatePanel ID="UpdatePanel" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="updateButton" EventName="Click"/>
</Triggers>
<ContentTemplate>
<asp:ListBox ID="lbUpdatedCompanies" runat="server" Height="300px" style="margin-top: 0px" Width="374px"></asp:ListBox>
<br/>
<asp:Button ID="updateButton" runat="server" OnClick="UpdateButtonClick" Text="Обновить"/>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress" runat="server" AssociatedUpdatePanelID="UpdatePanel">
<ProgressTemplate>
<img src="../Icons/loading_spinner.gif" style="height: 60px; width: 65px" alt=""/>
</ProgressTemplate>
</asp:UpdateProgress>
On button click I'm trying to add items to listbox in loop:
foreach (var company in companies)
{
lbUpdatedCompanies.Items.Add(company.NAME);
Thread.Sleep(1000);
}
But the listbox shows changes after loop exit when all items are added
I have a weird problem. I can't access some of my server controls from my codebehind. I've looked around and can only find answers for situations where you can't find ANY controls and I've tried all solutions I've found here on stack. re-creating designer file, deleting temp data, renaming controls etc. Nothing works.
The weird thing is that I can access every controller I put outside my ListView element. But everything inside will not get generated in my aspx.designer.cs file.
Code:
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolderMid" runat="server">
<h2><asp:Label ID="LabelCat" runat="server" Text=""></asp:Label></h2>
<asp:HiddenField ID="HiddenFieldID" runat="server" />
<br />
<div class="list-group">
<asp:ListView ID="ListViewSearch" runat="server" DataSourceID="SqlDataSourceWebsite" DataKeyNames="WebsiteID">
<EmptyDataTemplate>
<table runat="server">
<tr>
<td>Darn</td>
</tr>
</table>
</EmptyDataTemplate>
<ItemTemplate>
<td>
<div class="row list-group-item">
<div class="">
<%# Eval("url") %>
</div>
<div class="col-xs-5">
<div class="pull-left">
<div>
<asp:LinkButton ID="BtnUp" runat="server" CssClass="btn btn-default btn-xs" CommandArgument='<%# Eval("websiteId").ToString() %>' OnClick="up_click"><i class="fa fa-chevron-up" style="color:green"></i></asp:LinkButton>
</div>
<div>
<asp:LinkButton ID="BtnDown" runat="server" CssClass="btn btn-default btn-xs" CommandArgument='<%# Eval("websiteId").ToString() %>' OnCommand="down_click"><i class="fa fa-chevron-down" style="color:red"></i></asp:LinkButton>
</div>
</div>
<div class="lbl-score">
<asp:Label ID="LabelScore" runat="server" Text="Score: "></asp:Label>
<asp:ScriptManagerProxy ID="ScriptManagerProxySearch" runat="server"></asp:ScriptManagerProxy>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Label ID="LabelRating" runat="server" Text=' <%# Eval("rating") %>'></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="BtnUp" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</div>
</div>
<div class="lbl-desc">
<asp:Label ID="LabelDesc1" runat="server" Text=' <%# Eval("Description1") + " | "%> '></asp:Label>
<asp:Label ID="LabelDesc2" runat="server" Text=' <%# Eval("Description2") %> '></asp:Label>
</div>
</div>
</td>
</ItemTemplate>
</asp:ListView>
</div>
<asp:SqlDataSource ID="SqlDataSourceWebsite" runat="server" ConnectionString="<%$ ConnectionStrings:WDBAPPConnectionString %>" SelectCommand="SELECT * FROM [Website] WHERE ([categoryId] = #HFID)">
<SelectParameters>
<asp:ControlParameter ControlID="HiddenFieldID" Name="HFID" Type="Int32" DefaultValue="0" />
</SelectParameters>
</asp:SqlDataSource>
</asp:Content>
I know there is a lot of code but basically the controls "LabeCat", "HiddenFieldID", "ListViewSearch" and "SqlDataSourceWebsite" show up in my aspx.designer.cs-file, but no other controls do, in other words; all controls before and after my ListView work fine. What could be wrong here? So confused.
In my page, I have 2 repeaters.In First repeater i have a LinkButton.On Item Command of first repeater link button i am populating second repeater.I am trying to avoid postback on each click but the UpdatePanel can not avoid post back.
Here is code.aspx
<asp:ScriptManager runat="server"></asp:ScriptManager>
<div>
<asp:UpdatePanel runat="server">
<ContentTemplate>
<asp:Repeater ID="rptIndvidualButtons" runat="server" onitemcommand="rptIndvidualButtons_ItemCommand">
<ItemTemplate>
<ul>
<li class="button">
<asp:LinkButton ID="lnkBtnIndvidual" runat="server" Text='<%#Eval("PackageType")%>'></asp:LinkButton>
</li>
</ul>
</ItemTemplate>
</asp:Repeater>
</div>
<div style="clear:both">
<asp:Repeater ID="rptIndvidual" runat="server">
<ItemTemplate>
<div runat="server" id="divBronzeIndvidual">
<ul class="pricing-table" id="ulBronze">
<li class="title">
<div class="item-title">
<asp:Label ID="lblIndvPkgName" runat="server" Text='<%#Eval("PackageName")%>'></asp:Label>
</div>
</li>
</ul>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="rptIndvidualButtons" />
</Triggers>
</asp:UpdatePanel>
From above code can any one help me??
try to call RegisterAsyncPostBackControl for the linkbuttons in rptIndvidualButtons.itemDataBound event
var lnkBtnIndvidual = (LinkButton)e.Item.FindControl("lnkBtnIndvidual")'
ScriptManager1.RegisterAsyncPostBackControl(lnkBtnIndvidual);
I have three dropdowns on a page.
(1) Holds Parking Structures - parkingArea
(2) Holds the levels for the selected (1) - ddParkingAreaLevel
(3) The slots available for (2) - ddAvailableParkingSlots
When someone changes (1), (2) is uploaded with the levels for (1) and then (3) is updated with the slots available for the level selected (2).
However, this just does not work. I am not very familiar with UpdatePanel and simply cant get it to work as intended.
They way it works now:
When I change (1), (2) is updated correctly and (3) loads the slots for (2). But, if I change (2), the UpdatePanel is triggered but slots are NOT loaded into (3) and (2) "jumps back" to SelectedIndex at value 0, and does not stay at the newly selected level.
Here is the code:
<div class="form-group" id="parkingArea" runat="server">
<label>Parking Area:</label>
<asp:DropDownList ID="ddParkingAreas" CssClass="form-control" runat="server"
style="width:240px;" onselectedindexchanged="ddParkingAreas_SelectedIndexChanged"
AutoPostBack="true"></asp:DropDownList>
</div>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div class="form-group">
<label>Level:</label>
<asp:DropDownList ID="ddParkingAreaLevel" CssClass="form-control" runat="server"
style="width:240px;" onselectedindexchanged="ddParkingAreaLevel_SelectedIndexChanged"
AutoPostBack="true"></asp:DropDownList>
</div>
</ContentTemplate>
<Triggers><asp:AsyncPostBackTrigger ControlID="ddParkingAreas"
EventName="SelectedIndexChanged" /></Triggers>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div class="form-group">
<label>Available Parking Slots:</label>
<asp:DropDownList ID="ddAvailableParkingSlots" CssClass="form-control"
runat="server" style="width:240px;"></asp:DropDownList>
</div>
</ContentTemplate>
<Triggers><asp:AsyncPostBackTrigger ControlID="ddParkingAreaLevel"
EventName="SelectedIndexChanged" /></Triggers>
</asp:UpdatePanel>
Hope any of you guys can help!
Regards,
Bob
Why not use one update panel for all cascading dropdowns?
<asp:UpdatePanel ID="udpMain" runat="server" ChildrenAsTriggers="true">
<ContentTemplate>
<div class="form-group" id="parkingArea" runat="server">
<label>Parking Area:</label>
<asp:DropDownList ID="ddParkingAreas" CssClass="form-control" runat="server" style="width:240px;" onselectedindexchanged="ddParkingAreas_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
</div>
<div class="form-group">
<label>Level:</label>
<asp:DropDownList ID="ddParkingAreaLevel" CssClass="form-control" runat="server" style="width:240px;" onselectedindexchanged="ddParkingAreaLevel_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
</div>
<div class="form-group">
<label>Available Parking Slots:</label>
<asp:DropDownList ID="ddAvailableParkingSlots" CssClass="form-control" runat="server" style="width:240px;"></asp:DropDownList>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddParkingAreas" EventName="ddParkingAreas_SelectedIndexChanged" />
<asp:AsyncPostBackTrigger ControlID="ddAvailableParkingSlots" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>