form doesn't submit

Discussion in 'ASP .Net' started by =?Utf-8?B?R2xvYmFsRGV2ZWxvcGVy?=, Dec 4, 2004.

  1. The following simple code which is supposed to enumerate the
    form and query variables does work in IE6 and FireFox but NOT
    in IE5. Could anyone advice me on this one???

    I think the issue has to do with the javascript line
    document.forms[0].submit();
    in the TestVar function but I just cannot see what is wrong
    with that call.

    <script runat="server">
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    Dim key, value As String
    Dim sb As New System.Text.StringBuilder

    sb.Append("<br>").Append(Date.Now.ToString("u")).Append("<br><br>")

    sb.Append("Form variables -----").Append("<br><br>")
    For Each key In HttpContext.Current.Request.Form.Keys
    sb.Append(key).Append(" =
    ").Append(HttpContext.Current.Request.Form(key)).Append("<br>")
    Next

    sb.Append("<br>").Append("<br>").Append("Request variables
    -----").Append("<br><br>")
    For Each key In HttpContext.Current.Request.QueryString.Keys
    sb.Append(key).Append(" =
    ").Append(HttpContext.Current.Request.QueryString(key)).Append("<br>")
    Next

    vars.Text = sb.ToString
    End Sub
    </script>
    <HTML>
    <HEAD><title>default</title></HEAD>
    <body>
    <script type="text/javascript">
    function TestVar()
    {
    var t = new Date();
    document.forms[0].elements["testvar1"].value=t;
    document.forms[0].submit();

    return true;
    }
    </script>
    <form id="Form1" name="Form1" method="post" runat="server">
    <input type="hidden" id="testvar1" value="Hej" runat="server"
    NAME="testvar1">
    <asp:Label ID="vars" Runat="server"></asp:Label>
    <a href="#" onclick="return TestVar();">Go</a>
    <input type="button" onclick="TestVar()" value="Go">
    </form>
    </body>
    </HTML>
     
    =?Utf-8?B?R2xvYmFsRGV2ZWxvcGVy?=, Dec 4, 2004
    #1
    1. Advertising

  2. I might add that you will find those lines of code executing at:
    http://www.mediaa2.com/default.aspx

    "GlobalDeveloper" wrote:

    > The following simple code which is supposed to enumerate the
    > form and query variables does work in IE6 and FireFox but NOT
    > in IE5. Could anyone advice me on this one???
    >
    > I think the issue has to do with the javascript line
    > document.forms[0].submit();
    > in the TestVar function but I just cannot see what is wrong
    > with that call.
    >
    > <script runat="server">
    > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles MyBase.Load
    > Dim key, value As String
    > Dim sb As New System.Text.StringBuilder
    >
    > sb.Append("<br>").Append(Date.Now.ToString("u")).Append("<br><br>")
    >
    > sb.Append("Form variables -----").Append("<br><br>")
    > For Each key In HttpContext.Current.Request.Form.Keys
    > sb.Append(key).Append(" =
    > ").Append(HttpContext.Current.Request.Form(key)).Append("<br>")
    > Next
    >
    > sb.Append("<br>").Append("<br>").Append("Request variables
    > -----").Append("<br><br>")
    > For Each key In HttpContext.Current.Request.QueryString.Keys
    > sb.Append(key).Append(" =
    > ").Append(HttpContext.Current.Request.QueryString(key)).Append("<br>")
    > Next
    >
    > vars.Text = sb.ToString
    > End Sub
    > </script>
    > <HTML>
    > <HEAD><title>default</title></HEAD>
    > <body>
    > <script type="text/javascript">
    > function TestVar()
    > {
    > var t = new Date();
    > document.forms[0].elements["testvar1"].value=t;
    > document.forms[0].submit();
    >
    > return true;
    > }
    > </script>
    > <form id="Form1" name="Form1" method="post" runat="server">
    > <input type="hidden" id="testvar1" value="Hej" runat="server"
    > NAME="testvar1">
    > <asp:Label ID="vars" Runat="server"></asp:Label>
    > <a href="#" onclick="return TestVar();">Go</a>
    > <input type="button" onclick="TestVar()" value="Go">
    > </form>
    > </body>
    > </HTML>
     
    =?Utf-8?B?R2xvYmFsRGV2ZWxvcGVy?=, Dec 4, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page