Nestled UpdatePanels causes full page postback - c#

I'm having issues with nestled, custom user controls that causes full page postbacks despite being encapsulated by an UpdatePanel.
The update panel:
<asp:Content ID="mainContentPane" ContentPlaceHolderID="mainContent" runat="server">
<asp:ScriptManager ID="smNetAjax" runat="server" />
<asp:UpdatePanel runat="server" UpdateMode="Conditional" ID="pnlAssetTabView">
<ContentTemplate>
<custom:AssetTabView runat="server" ID="tvAddAssets" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
The AssetTabView-control:
<custom:TabView runat="server" ID="tvTabView" OnSelectedTabChanged="tvTabView_SelectedTabChanged" />
<custom:AssetList runat="server" ID="dalAssetList" />
And finally the TabView whose links causes full page postback:
<SelectedItemTemplate>
<div class="tab current">
<div class="left"></div>
<asp:LinkButton ID="ExtendedLinkButton1" runat="server"><span><%# DataBinder.Eval(Container.DataItem, "HeaderText") %></span></asp:LinkButton>
<div class="right"></div>
</div>
</SelectedItemTemplate>
<ItemTemplate>
<div class="tab">
<div class="left"></div>
<asp:LinkButton OnCommand="ProcessTabSelection" CommandArgument='<%# Container.ItemIndex %>' ID="ExtendedLinkButton2" runat="server" TabIndex='<%# TabIndex + Container.ItemIndex %>'><span><%# DataBinder.Eval(Container.DataItem, "HeaderText") %></span></asp:LinkButton>
<div class="right"></div>
</div>
</ItemTemplate>
<FooterTemplate>
</div>
</FooterTemplate>
I'm really running out of ideas right and I'm desperate for any ideas that you might have! Thank you.

You have option of ProxyScriptManager. You don't need name of update panel, u can iterate to control list till closest-upward update panel is found.

Related

ASP.NET Button inside listview vanishes after click when using submit behavior set as false

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

Need to add 'for' attibutes to labels inside a ListView control of an ASP.NET page

I have something like this
<asp:ListView ID="lvOptions" runat="server"">
<LayoutTemplate>
<p>Select an option<span>*</span></p>
<div class="row">
<asp:Literal runat="server" ID="groupPlaceHolder"></asp:Literal>
</div>
<div class="row">
<div class="w100">
<label>
Other types:</label>
<asp:DropDownList ID="ddlOtherTypes" runat="server" DataTextField="Description" DataValueField="Id"
AutoPostBack="true" Enabled="false"
</asp:DropDownList>
</div>
</div>
</LayoutTemplate>
<GroupTemplate>
<asp:Literal runat="server" ID="itemPlaceHolder"></asp:Literal>
</GroupTemplate>
<ItemTemplate>
<span class="wrap-w50">
<asp:RadioButton runat="server" ID="rdbOption" AutoPostBack="true" />
<label>
<%# Eval("Description") %></label>
</span>
</ItemTemplate>
</asp:ListView>
And I got here two labels, one fot the Other types DropDownList, and another for each RadioButton.
For this labels, I need to add a "for" attribute, and I need the clientID but, if I try to write the attibute like:
for="<%= ddlOtherTypes.ClientID %>"
for="<%= rdbOption.ClientID %>"
I got the error: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
Any suggestions please?
Thank you in advance.

Ajax Tab Container loads the first tab always when fire an event

I have an AJAX tab container that contains two tab panels.
The problem when I fire an event on the second tab it reloads the first tab.
Any help? Suggestions? below is a sample of the aspx code
<AJAX:TabContainer runat="server" ID="tcMain" ActiveTabIndex="0">
<AJAX:TabPanel runat="server" ID="tpTab1" TabIndex="1">
<HeaderTemplate>
Tab1
</HeaderTemplate>
<ContentTemplate>
<div runat="server" id="div1">
<asp:UpdatePanel ID="upTab1" runat="server">
<ContentTemplate>
//entry and events
</ContentTemplate>
</asp:UpdatePanel>
</div>
</ContentTemplate>
</AJAX:TabPanel>
<AJAX:TabPanel runat="server" ID="tpTab2" TabIndex="2">
<HeaderTemplate>
Tab2
</HeaderTemplate>
<ContentTemplate>
<div runat="server" id="div2">
<asp:UpdatePanel ID="upTab2" runat="server">
<ContentTemplate>
// entry and events
</ContentTemplate>
</asp:UpdatePanel>
</div>
</ContentTemplate>
</AJAX:TabPanel>
</AJAX:TabContainer>
Most likely this is because of page post-back happening.you can manage the data using ViewState property this link may solve your issue HElP
.

Certain controls won't get generated in aspx.designer.cs-file

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.

Create Loading animation before navigating to another page and disable all conrols on it during animation

I have a button on Page 1 and when the button click event occurs, I had to do some process that takes around 2-3 seconds. So, I want to Put a Loading Image in Center and disable all other controls on the Page 1.
I tried using UpdatePanel :
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button runat="server" Text="Button" onclick="Unnamed1_Click" />
<asp:Label runat="server" Text="Label" ID="lbl"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1" >
<ProgressTemplate>
<div id="IMGDIV1" align="center" valign="middle" runat="server" style="position: absolute;visibility:visible;vertical-align:middle;border-style:none;border-color:black;background-color:transparent;">
<asp:Image ID="Image1" runat="server" ImageUrl="~/ajax-loader (1).gif" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
But the controls did not get disabled. Any Solution or Javascript ??
Also I want that it should work if want to stay on the same page.
why dont yu use telerik radgrid loading panel ?
http://www.telerik.com/help/aspnet-ajax/ajax-center-loadingpanel.html

Categories

Resources