Problem with User Control Postback
Hello,
I created News listing web user control and I have pager at the bottom, which is basically repeater control with link buttons of page number. It works when I put into separate .aspx page, but it doesn't work when I register it with sitefinity.
I can see first page, but clicking on any of the other pages [Page number 2,3,4...], shows blank page.
Please help.
<asp:MultiView runat="server" ID="multiview1" ActiveViewIndex="0">
<asp:View ID="viewNewsListing" runat="server">
<asp:Repeater ID="rptNewsList" runat="server" OnItemDataBound="rptNewsList_ItemDataBound">
<HeaderTemplate>
<ul class="sf_newsList">
</HeaderTemplate>
<ItemTemplate>
<li>
<p class="sf_newsDate">
<asp:Literal ID="ltrPublication_Date" runat="server" Text='<%# Eval("DateCreated","0:dd MMM") %>' />
</p>
<h2 class="sf_newsTitle">
<asp:HyperLink ID="hlinkTitle" runat="server" Text='<%# Eval("Title") %>' NavigateUrl='<%# Request.Url.ToString() + "?Id=" + Eval("UrlName") %>' />
</h2>
<p>
<asp:Literal ID="ltrSummary" runat="server" Text='<%# (Eval("Summary").ToString().Length > 100) ? Eval("Summary").ToString().Substring(0, 150) + "..." : Eval("Summary").ToString() %>'></asp:Literal>
</p>
<p>
<asp:HyperLink ID="hlinkReadMore" runat="server" Text="...read more" NavigateUrl='<%# "~/NewsDetails.aspx?Id=" + Eval("UrlName") %>' />
</p>
<uc1:ShareThis id="ShareThis1" runat="server" />
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
<div>
<asp:Literal runat="server" ID="ltrPaging"></asp:Literal>
</div>
<div>
<asp:Repeater runat="server" ID="rptPaging" OnItemDataBound="rptPaging_ItemDataBound" >
<HeaderTemplate>
<div>
<asp:LinkButton runat="server" ID="lkbPrevious" CssClass="previousbutton" Text="Previous"
OnClick="lkbPrevious_Click" />
<div>
</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton runat="server" ID="lkbPage" OnClick="lkbPage_Click"></asp:LinkButton>
</ItemTemplate>
<FooterTemplate>
</div>
<asp:LinkButton runat="server" ID="lkbNext" CssClass="nextbutton" Text="Next" OnClick="lkbNext_Click"/>
</div>
</FooterTemplate>
</asp:Repeater>
</div>
</FooterTemplate>
</asp:Repeater>
</asp:View>
<asp:View ID="viewNewsDetails" runat="server">
<div class="sf_singleNews">
<asp:HyperLink ID="hlinkbackToList" Text="Back to listing" CssClass="sf_back" runat="server"></asp:HyperLink>
<p class="sf_newsDate">
<asp:Literal ID="ltrPublication_Date" runat="server" />
</p>
<h2 class="sf_NewsTitle">
<asp:Literal ID="ltrTitle" runat="server"></asp:Literal>
</h2>
<p>
<asp:Literal ID="ltrcontent" runat="server"></asp:Literal>
</p>
<uc1:ShareThis ID="ShareThis1" runat="server" />
</div>
</asp:View>
</asp:MultiView>
Hello Vaibhavi,
Could you try enabling the ViewState for the page where you drop your control? It is done when from the Pages grid you select Actions -> Title & Properties -> Enable ViewState
All the best,Thanks you Lubomir !
I'd knew that the problem was the ViewState of the master page, but i didn't realize how to fix it.
now everithing is OK
"AutoPostBack = true" doesn't work for my page. It looks similar problem as its in the user control. I tried enabling viewstate of page from sitesinity admin where the control is placed and also I tried enabling viewstate from code for master page. But no luck.
<asp:DropDownList ID="ddl1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddl1_SelectedIndexChanged">
<asp:ListItem Text="search engine" Value="0"></asp:ListItem>
<asp:ListItem Text="press advertising" Value="1"></asp:ListItem>
<asp:ListItem Text="word of mouth" Value="2"></asp:ListItem>
<asp:ListItem Text="other web sites" Value="3"></asp:ListItem>
</asp:DropDownList>
mario,
Did you set EnableViewState="true" in .master page using code? I don't see any way to set it using sitefinity.
Vaibhavi,
I didn't need to add anything to my code, just check the "enable page viewstate" in sitefinity
in the "Pages" section go to: Actions->Title & Properties -> "Enable ViewState" and that's it.
Hope you solve this.
It doesn't work. Please let me know the fix asap.
Hi Vaibhavi,
I created a small video that illustrates how I managed to reproduce the effect that you need. Please let me know if this is enough. I also didn't check EnableViewStarte as it is not needed.
http://screencast.com/t/GMQCEG8cW