MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

Pager problem (Closed) (Mono Support )

Viewed 15706 time(s), 5 post(s) 11/21/2011 6:16:38 PMby Maxim
Maxim

Maxim

11/21/2011 6:16:38 PM
Hi!
I use standart MonoX Pager in my control, it's works fine. But when some controls at this same page contains a data(text in textbox), then after page switching, page goes to refresh with GET query parameters(no PostBack), and alldata get lost.

So please help me with one of ways:
1. Switch Off full page refresh of pager. Query parameters no necessary for me, simple PostBack. Can I do this?
2. Tell me how simple store and load data to page using MonoX features. :)
This content has not been rated yet. 
319 Reputation 30 Total posts
khorvat

khorvat

11/22/2011 8:01:41 AM
Hi Maxim,

MonoX has two types of pagers (two pager templates) as you may noticed, the SEO pager that you are probably using and the Postback pager. If you want your data to be preserved on the page you will probably need a postback pager and you can simple change the template for the pager to postback one and you will not be redirected to the same page and loose the data.

1. Switch Off full page refresh of pager. Query parameters no necessary for me, simple PostBack. Can I do this?
Yes, please let me know how do you use the pager so I can show you how to change the pager template. Postback pager template can be found in the following location: ~\App_Templates\Default\PagerTemplates\PostbackPager.ascx

2. Tell me how simple store and load data to page using MonoX features. :)
To store and load data on per page basis you can use simple ASP.NET ViewState mechanism (or if we are talking about the post back data stored in the controls such as TextBox, you just need to switch to postback pager and everything will work out of the box). If you choose to use the ViewState can you simple put your data into a ViewState and have no worries as MonoX has a WAO ViewState provider that will optimize the ViveState storage for you.

Let me know if you need anything else.

Regards
This content has not been rated yet. 
15993 Reputation 2214 Total posts
Maxim

Maxim

11/22/2011 9:07:05 AM
I've been used a simple MonoSoftware.Web.Pager. Now I try to use your variant, and have a problem:

Unable to cast object of type 'System.Web.UI.WebControls.Panel' to type 'MonoSoftware.Web.Pager.Pager'.

Description: An unhandled exception occurred during
the execution of the current web request. Please review the stack trace
for more information about the error and where it originated in the
code.
Exception Details: System.InvalidCastException:
Unable to cast object of type 'System.Web.UI.WebControls.Panel' to type
'MonoSoftware.Web.Pager.Pager'.
Source Error:
Line 52: {
Line 53: get { return uxPager.Pager.PageSize; }
Line 54: set { uxPager.Pager.PageSize = value; }
Line 55: }
Line 56:


Where uxPager is the pager.

protected global::MonoSoftware.MonoX.Controls.MonoXPagerTemplate uxPager;

Can you show me a little example of correct usage PostbackPager?
This content has not been rated yet. 
319 Reputation 30 Total posts
imarusic

imarusic

11/22/2011 3:18:19 PM
Hi,

here is an example on how to use MonoX Postback pager with repeater:

Markup:

<asp:Repeater ID="repeater" runat="server">
    <HeaderTemplate>
        <table cellpadding="0" cellspacing="0" width="100%">
            <tr>
                <th>
                    First column
                </th>               
            </tr>
    </HeaderTemplate>
    <ItemTemplate>
        <tr>
            <td>
                <%# ((YourEntity)(Container.DataItem)).CreatedOn %>
            </td>                         
        </tr>
        </ItemTemplate>
    <FooterTemplate>
        </table>
    </FooterTemplate>
</asp:Repeater>
     
<mono:Pager ID="pager" runat="server" AutoPaging="false" AllowCustomPaging="true" EnableViewState="true" PageSize="10" NumericButtonCount="5">
    <PagerTemplate>
        <mono:PagerTemplate ID="pagerTemplate" runat="server" />
    </PagerTemplate>
</mono:Pager>

Codebehind:

private void BindData()
 {
    int recordCount = 0;
    EntityCollection<YourEntity> yourEntities = YourRepository.GetInstance().GetYourEntities(pager.CurrentPageIndex + 1, pager.PageSize, out recordCount);
 
    PagerUtility.BindPager(pager, BindData, repeater, yourEntities, recordCount);
}

protected override void OnInit(EventArgs e)
{
    base.OnInit(e);
    pager.PageIndexChanged += new MonoSoftware.Web.Pager.PageChangedEventHandler(pager_PageIndexChanged);
 
}


protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
 
    if (!IsPostBack)
    {
        BindData();
    }
    else
        pager.DataBind();
}

void pager_PageIndexChanged(object source, MonoSoftware.Web.Pager.PageChangedEventArgs e)
{
    pager.CurrentPageIndex = e.NewPageIndex;
    BindData();
}



Regards
Rated 5.00, 1 vote(s). 
3016 Reputation 428 Total posts
Maxim

Maxim

11/23/2011 9:06:09 AM
Thanks for answer, first problem was in wrong ASPX declaration.
Second was function:
InitPagerTemplate(uxPager, PagerQueryString, PagerQueryStringSuffix);
Who dissalow to use PostBacks. After commenting it all works fine!
This content has not been rated yet. 
319 Reputation 30 Total posts