RadDataPager is going back to the first selected page in response.redirecting!

4 posts, 0 answers
  1. shemein
    shemein avatar
    28 posts
    Member since:
    Mar 2014

    Posted 27 May 2014 Link to this post

    Hello,

    I have used RadDataPager as the navigation bar of my web pages. in RadDataPager1_PageIndexChanged event in MasterPage I have used Response.Redirect to the url of new page to navigate the webpages. everything is working well except the selected page that is going back to 1 in the RadDatapager. I need to highlight the page number that the user is in  after Response.Redirect to that page. It sounds that Response.Redirect is refreshing the MasterPage and causes the content pages work individualy. Would you please help me to fix it?

    My code is:

    ​ protected void RadDataPager1_PageIndexChanged(object sender, RadDataPagerPageIndexChangeEventArgs e)
    {


    DataTable dt = (DataTable) Session["PageDetails"];
    int[] PageNumber = (dt.AsEnumerable().Select(s => s.Field<int>("PageNumber"))).ToArray();
    string[] pageUrlStrings = (dt.AsEnumerable().Select(f => f.Field<string>("CurrentPage"))).ToArray();
                    
                     Label1.Text = Convert.ToString(e.NewStartRowIndex + 1);

    for (int i = 0; i < PageNumber.Length; i++)
    {

    if (PageNumber[i] == Convert.ToInt32(Label1.Text))
    {

                            
                                Response.Redirect(pageUrlStrings[i]);



    }

    }

    }
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 27 May 2014 in reply to shemein Link to this post

    Hi shemein,

    Please try the below C# code snippet open a page in new window.

    C#:
    protected void ProductsListDataPager_PageIndexChanged(object sender, Telerik.Web.UI.RadDataPagerPageIndexChangeEventArgs e)
    {
        string url = "http://www.telerik.com";
        Response.Write("<script>window.open('" + url + "');</script>");
    }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. shemein
    shemein avatar
    28 posts
    Member since:
    Mar 2014

    Posted 30 May 2014 in reply to Princy Link to this post

    Hi Princy,

    Thanks for your reply but my point wasn't about it. I mean when page is posting back the selected page in raddatapage will be again number 1. I want to know how I can remove the selected highlighting  from the first page that is by default?
    another question: why when I create the buttons as IButtons in creating controls and use the button.postback="URL"  the url doesn't change the address in the toolbar but also it goes to the end of the first page like this:
    http://localhost:/ section/entity.aspx ~/section/glob.aspx
    Would you please help me? I really need to know about it. It has taken several days but no result:(
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 30 May 2014 in reply to shemein Link to this post

    Hi shemein,

    The below sample code snippet will highlight the correct page after postback, this is the default behavior of the control.

    ASPX:
    <telerik:RadListView ID="RadListView1" Width="97%" AllowPaging="True" runat="server" DataSourceID="SqlDataSource1" ItemPlaceholderID="ProductsHolder" DataKeyNames="ProductID">
               <LayoutTemplate>
                   <fieldset style="max-width: 920px;" id="FieldSet1">
                       <legend>Products</legend>
                       <asp:Panel ID="ProductsHolder" runat="server" />
                       <table cellpadding="0" cellspacing="0" width="100%;" style="clear: both;">
                           <tr>
                               <td>
                                   <telerik:RadDataPager runat="server" ID="ProductsListDataPager"  PagedControlID="RadListView1"  onpageindexchanged="ProductsListDataPager_PageIndexChanged">
                                       <Fields>
                                           <telerik:RadDataPagerButtonField FieldType="FirstPrev" />
                                           <telerik:RadDataPagerButtonField FieldType="Numeric" />
                                           <telerik:RadDataPagerPageSizeField PageSizes="9,18,27,45" />
                                           <telerik:RadDataPagerButtonField FieldType="NextLast" />
                                       </Fields>
                                   </telerik:RadDataPager>
                               </td>
                           </tr>
                       </table>
                   </fieldset>
               </LayoutTemplate>
               <ItemTemplate>
                   <div style="float: left;">
                       <table cellpadding="0" cellspacing="0" style="width: 230px; height: 118px">
                           <tr>
                               <td style="width: 20%;">
                                   Name:
                               </td>
                               <td style="width: 80%; padding-left: 5px;">
                                   <%# Eval("ProductName") %>
                               </td>
                           </tr>
                       </table>
                   </div>
               </ItemTemplate>
           </telerik:RadListView>

    C#:
    protected void ProductsListDataPager_PageIndexChanged(object sender, Telerik.Web.UI.RadDataPagerPageIndexChangeEventArgs e)
       {
           string url = "http://www.telerik.com";
           Response.Write("<script>window.open('" + url + "');</script>");
       }

    I am not sure about your second requirement, please elaborate your requirement.

    Thanks,
    Princy.
Back to Top