How to submit a form using javascript when we use radAjaxPanel

2 posts, 1 answers
  1. mastermehdi
    mastermehdi avatar
    39 posts
    Member since:
    Apr 2010

    Posted 21 Aug 2011 Link to this post

    Hi

    I use this code for submit my form to our bank gateway:

     

    <%@ Page Language="C#" %>

    <!DOCTYPE html>

    <script runat="server">

        protected void submit(object sender, EventArgs e)

        {

            ClientScript.RegisterStartupScript(typeof(Page),

                "ClientScript",

                "<script language='javascript' type='text/javascript'> postRefId();</"+"script> ",

                false);

        }

    </script>

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head runat="server">

        <title>test</title>

        <script language="javascript" type="text/javascript">

            function postRefId() {

                var form = document.createElement("form");

                form.setAttribute("method", "POST");

                form.setAttribute("action", "http://bmi.ir");

                form.setAttribute("target", "_self");

                document.body.appendChild(form);

                form.submit();

                document.body.removeChild(form);

            }

        </script>

    </head>

    <body>

        <form id="form1" runat="server">

            <div>

                 <asp:Button ID="Button1" runat="server"

                 Text="Button"

                 OnClick="submit" />

            </div>

        </form>

    </body>

    </html>

     

    But when I use RadAjaxPanel like this, I can’t submit my form:

    <%@ Page Language="C#" %>

    <!DOCTYPE html>

    <script runat="server">

        protected void submit(object sender, EventArgs e)

        {

            ClientScript.RegisterStartupScript(typeof(Page),

                "ClientScript",

                "<script language='javascript' type='text/javascript'> postRefId();</"+"script> ",

                false);

        }

    </script>

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head runat="server">

        <title>test</title>

        <script language="javascript" type="text/javascript">

            function postRefId() {

                var form = document.createElement("form");

                form.setAttribute("method", "POST");

                form.setAttribute("action", "http://bmi.ir");

                form.setAttribute("target", "_self");

                document.body.appendChild(form);

                form.submit();

                document.body.removeChild(form);

            }

        </script>

    </head>

    <body>

        <form id="form1" runat="server">

            <div>

                <tlk:RadScriptManager ID="RadScriptManager1" runat="server" />

                <tlk:RadAjaxPanel ID="RadAjaxPanel1" runat="server">

                        <asp:Button ID="Button1" runat="server"

                        Text="Button"

                        OnClick="submit" />

                </tlk:RadAjaxPanel>

            </div>

        </form>

    </body>

    </html>

     

    How can I fix it?

  2. Answer
    Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 23 Aug 2011 Link to this post

    Hi Mastermehdi,

    i would suggest you to review the following help topic which elaborate son executing client script after Ajax request.
    http://www.telerik.com/help/aspnet-ajax/ajax-execute-custom-javascript.html

    Regards,
    Maria Ilieva
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top