ASP .Net隐藏字段设置但不在IE中发布

时间:2016-06-15 15:21:10

标签: javascript html asp.net internet-explorer internet-explorer-11

在我的网络表单中,我有一个ASP隐藏字段: <asp:HiddenField ID="HiddenField1" runat="server" OnValueChanged="HiddenField1_ValueChanged" />我当前正在设置此字段客户端的值

document.getElementById("ContentPlaceHolder1_HiddenField1").value = type + pngUrl;

然后我打电话 document.forms[0].submit();发布页面。 隐藏字段的更改值在chrome和firefox中成功发布,但在IE中,DOM Viewer表示数据位于隐藏字段内,但在检查帖子时,隐藏字段的区域完全为空。 (这是在IE 11中)

编辑:修复但之前的示例代码,寻找解释为什么修复它。

工作版     

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <script src="webcam.min.js"></script>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        <asp:HiddenField ID="HiddenField1" runat="server" />
        <div id="CameraDivtest"></div>
             <input type="button" id="start" value="startCamera" onclick="videoCall('test')" />
        <input type="button" value="take picture" id="picButtonKey" />



    </div>
    </form>
     <script>
         var c;
         var v;
         var con;
         function videoCall(type) {


             Webcam.set({
                 width: 600,
                 height: 420
             });
             Webcam.attach('#CameraDiv' + type);

             function goingGrey() {
                 Webcam.snap(function (data_uri, canvas, context) {
                     var pngUrl = data_uri
                     document.getElementById("<%=HiddenField1.ClientID%>").value = type + pngUrl;
                     document.forms[0].submit();


                });

            }


            document.getElementById("picButtonKey").addEventListener("click", function (e) {
                goingGrey();


            });


        }

    </script>
</body>
</html>

破碎的版本

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <script src="webcam.min.js"></script>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        <asp:HiddenField ID="HiddenField1" runat="server" />
        <div id="CameraDivtest"></div>
             <input type="button" id="start" value="startCamera" onclick="videoCall('test')" />
        <input type="button" value="take picture" id="picButtonKey" />



    </div>
    </form>
     <script>
         var c;
         var v;
         var con;
         function videoCall(type) {


             Webcam.set({
                 width: 600,
                 height: 420
             });
             Webcam.attach('#CameraDiv' + type);

             function goingGrey() {
                 Webcam.snap(function (data_uri, canvas, context) {
                     var pngUrl = data_uri
                     document.getElementById("<%=HiddenField1.ClientID%>").value = type + pngUrl;



                });

            }


            document.getElementById("picButtonKey").addEventListener("click", function (e) {
                goingGrey();
    document.forms[0].submit();


            });


        }

    </script>
</body>
</html>

0 个答案:

没有答案