This is a migrated thread and some comments may be shown as answers.

cross-page posting using RadButton does not work

6 Answers 138 Views
Button
This is a migrated thread and some comments may be shown as answers.
ck
Top achievements
Rank 1
ck asked on 13 Mar 2013, 02:09 PM
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

6 Answers, 1 is accepted

Sort by
0
Danail Vasilev
Telerik team
answered on 18 Mar 2013, 08:21 AM
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.
0
ck
Top achievements
Rank 1
answered on 18 Mar 2013, 04:49 PM
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
0
ck
Top achievements
Rank 1
answered on 19 Mar 2013, 02:30 PM
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
0
Danail Vasilev
Telerik team
answered on 21 Mar 2013, 04:47 PM
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.
0
Spimac
Top achievements
Rank 1
answered on 15 May 2013, 01:48 PM
Hi,

Any news about this issue?

Best regards.
0
Danail Vasilev
Telerik team
answered on 20 May 2013, 03:26 PM
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.
Tags
Button
Asked by
ck
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
ck
Top achievements
Rank 1
Spimac
Top achievements
Rank 1
Share this question
or