Problem with User Control Postback

Posted by Community Admin on 04-Aug-2018 13:13

Problem with User Control Postback

All Replies

Posted by Community Admin on 13-Oct-2011 00:00

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>

Posted by Community Admin on 17-Oct-2011 00:00

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,
Lubomir Velkov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 22-Oct-2011 00:00

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

Posted by Community Admin on 25-Oct-2011 00:00

"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>

Posted by Community Admin on 25-Oct-2011 00:00

mario,
Did you set EnableViewState="true" in .master page using code? I don't see any way to set it using sitefinity.

Posted by Community Admin on 25-Oct-2011 00:00

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.

Posted by Community Admin on 03-Nov-2011 00:00

It doesn't work. Please let me know the fix asap.

Posted by Community Admin on 07-Nov-2011 00:00

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

Kind regards,
Lubomir Velkov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed