日期:2014-05-17  浏览次数:20941 次

.Net中html控件值获取的一种方法
[size=medium]
<body>
    <%-- 加上from并设置runat="server" --%>
    <form id="frm" runat="server">
       <%-- Html控件 --%>
        <select name="Select1">
            <option value="1">Two</option>
        </select>
        <input name="txtVal" type="text" value="111" />
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
    </form>
</body>


protected void Page_Load(object sender, EventArgs e)
    {
        //利用Repuest获取htmml表单的值
        string val = this.Request["Select1"];
        string val1 = this.Request["txtVal"];
        Response.Write(val + "," + val1);
    }


输出结果  1,111
[/size]