在Firefox下,利用javascript动态创建了一个文本框<input id="Txt1" name="Txt1" />,然后我在服务器端Request["Txt1"](Request.Form、Request.Params、Request.QueryString和Request.Form.Get()都试过了),都无法获取到该值。请问是为什么?相同的代码在IE下就一切正常。

解决方案 »

  1.   

    Request获取的是name的值,用firebug来看看js创建的表单name值是不是Txt1
      

  2.   

    var ORow,oCell;
    oRow=Tab.insertRow(-1);   //Tab是表ID
    oRow.style.height="25px";oCell = document.createElement("td"); 
    oCell.id="td1";
    oCell.style.width="150px";
    oCell.innerHTML=SetHTMLControl();
                
    oRow.appendChild(oCell); 
    //************
    function SetHTMLControl()
    {
            var txt=document.createElement("input");
            txt.id="Txt1";
            txt.Name="Txt1";
            txt.style.width="95%";
            txt.maxLength="20";
            txt.title="";
            txt.style.textAlign="center";
            
            return txt.outerHTML;
    }
      

  3.   

    动态创建好像不对的哦:<html>
    <body>
    <input type=button value=aaaaa onclick="alert(document.getElementById('Txt1').value)"/>
    </body>
    </html>
    <script>
    var oTable = document.createElement("table");
    document.body.appendChild(oTable);
    var oRow = oTable.insertRow(-1);  //Tab是表ID 
    oRow.style.cssText="height:25px"; var oCell = oRow.insertCell(-1);
    oCell.style.cssText="width:150px"; 
    oCell.innerHTML=SetHTMLControl(); //************ 
    function SetHTMLControl() 

            var txt=document.createElement("input"); 
            txt.id="Txt1"; 
            txt.Name="Txt1"; 
            txt.style.width="95%"; 
            txt.maxLength="20"; 
            txt.title=""; 
            txt.style.textAlign="center"; 
            
            return txt.outerHTML; 
    }
    </script>