cross-page posting using RadButton does not work

7 posts, 0 answers
  1. ck
    ck avatar
    28 posts
    Member since:
    Mar 2013

    Posted 13 Mar 2013 Link to this post

    Hi,
    I am using RadButton to cross post a page, NewOrder.aspx, to another page,SaveOrder.aspx. the form is submitted and processed in the target page but the browser stays at the first page.
    if i change the RadButton to asp:Button, it works and SaveOrder.aspx is displayed.
    here's my markup for the button in NewOrder.aspx that is submitting to SaveOrder.aspx

    <telerik:RadButton ID="BtnSubmirOrder" runat="server" ButtonType="StandardButton" AutoPostBack="true"
                    Text="Place order" PostBackUrl="SaveOrder.aspx">
     </telerik:RadButton>

    in SaveOrder.aspx i have this
    protected void Page_Load(object sender, EventArgs e)
        {
            if (PreviousPage==null || !PreviousPage.IsCrossPagePostBack)
                Response.Redirect("~/Default.aspx");
     
            var referencingPage = PreviousPage as NewOrder;
            int id = Int32.Parse(referencingPage.SelectedPublicationId);
     
     
            DateTime neededBy = referencingPage.SelectedOrderDate;
     
            LblSummaryIsbn.Text = referencingPage.SelectedIsbn;
            LblSummaryNbrCopies.Text = referencingPage.NbrOfOrderedCopies;
            DateTime orderDate = DateTime.Now;
            LblSummaryOrderDate.Text = orderDate.ToShortDateString();
            LblSummaryTitle.Text = referencingPage.SelectedPublicationTitle;
            int quantity = Int32.Parse(referencingPage.NbrOfOrderedCopies);
            StockContainer _context = new StockContainer();
            Order newOrder = Order.CreateOrder(orderDate, quantity, neededBy, id);
            _context.Orders.AddObject(newOrder);
            _context.SaveChanges();
        }

    basically the user fills an order in NewOrder.aspx and submits it using the RadButton to SaveOrder.aspx where it will be saved . SaveOrder.aspx will return some information back to the user. its Page_Load method executes but the browser stays at NewOrder.aspx. what i am doing wrong? thanks
  2. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1493 posts

    Posted 18 Mar 2013 Link to this post

    Hi Chad,

    I have tried to reproduce your issue but to no avail. You can watch a short video with the test here, and then tell if I am missing something with the test.

    Could you confirm the version of RadControls as well as the browsers and their version under which you are having the unexpected behavior? Could you also try to reproduce the issue with the sample I have attached and then tell us what changes you have made, so that we can proceed further with the investigation? Note that I have removed parts of your code behind in order to run the sample.

    Regards,
    Danail Vasilev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. ck
    ck avatar
    28 posts
    Member since:
    Mar 2013

    Posted 18 Mar 2013 Link to this post

    Hi, thanks for replying.

    I am using RadControls for ASP.NET AJAX Q1 2013. I tested on both Chrome 25.0.1 and firefox 19.0.2 on windows 7.
    I will try to reproduce with the sample and let you know.

    cheers
  5. ck
    ck avatar
    28 posts
    Member since:
    Mar 2013

    Posted 19 Mar 2013 Link to this post

    Hi, i think i found out why it is not working.
    my RadButton is inside a RadAjaxPanel so it could be that, when the button is clicked, an ajax request is initiated instead of a form submit. this explains why my code behind of SaveOrder.aspx executed without the browser leaving the page. to confirm i put the RadButton outside the RadAjaxPanel and this time it worked.
    I tried defining a client click handler for the button and then cancelling the event inside it but 
    apparently the RadButtonEventArgs object does not provide a method to do that. 
    please advise.

    <telerik:RadButton ID="BtnSubmirOrder" runat="server"  UseSubmitBehavior="true"
                        ButtonType="StandardButton" AutoPostBack="true"
                        Text="Place order"
                        PostBackUrl="SaveOrder.aspx" onClientClicked="submitForm">

    function submitForm(sender,eventArgs){
    eventArgs.set_cancel(true);
    document.forms[0].action="SaveOrder.aspx";
    document.forms[0].submit();
    }

    cheers
  6. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1493 posts

    Posted 21 Mar 2013 Link to this post

    Hi Chad,

    Thank you for the clarification.

    I was able to reproduce the unexpected behavior. Our developers will further investigate on this regard, as this is a more specific scenario. For the time being you can monitor and comment on it in our feedback portal here.

    I have also updated your Telerik points, for reporting this issue.

    All the best,
    Danail Vasilev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  7. Spimac
    Spimac avatar
    7 posts
    Member since:
    Jan 2013

    Posted 15 May 2013 Link to this post

    Hi,

    Any news about this issue?

    Best regards.
  8. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1493 posts

    Posted 20 May 2013 Link to this post

    Hello Paulo,

    The status of this issue is not updated, as our developers are currently working on tasks with higher priority. For the time being you can use:
    • Either a RadButton (ButtonType="LinkButton") and set its NavigateUrl to the page that you want to be redirected
    • OR a RadButton (ButtonType="StandardButton") and use its OnClientClicking event handler to cancel the postback and redirect to the desired page through window.location.href. For example:

    JavaScript:

    <script type="text/javascript">
        function OnClientClicking(sender, args) {
     
            window.location.href = "http://www.bing.com";
            args.set_cancel(true);
     
        }
    </script>

    ASP:
    <telerik:RadButton ID="RadButton1" runat="server" PostBackUrl="http://www.bing.com"
        OnClientClicking="OnClientClicking" Text="Click" />

    You can also follow the feedback item for this issue in order to get updates on its status.


    All the best,
    Danail Vasilev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017