开发者

HTML forms in ASP.NET

Hello all how to use HTML text field instead of ASP.NET textbox.?

How to write C# code开发者_如何学JAVA to make use of HTML forms instead of ASP.NET


EDIT:

<form id="form1" runat="server">
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <input id="Text1" type="text" runat="server" />

    <asp:Button ID="Button5"
        runat="server" Text="Button" OnClick="button5_click" />
    <div>


        <script runat="server">
            protected void button5_click(object sender, EventArgs e)
            {
                Text1.Value = "Hello";
            }
        </script>


</form>


Instead of using or whatever server control, just type in the standard type tags or whichever HTML control you want.

If you want to be able to access them from your code-behind, then just include a runat="server" value with each HTML tag and make sure you give it an ID.


You need to retrieve the value from the HTTP request's Form collection:

<input type="text" name="MyTextField" />

Code behind:

string value = Request.Form["MyTextField"];


This question doesn't make much sense. You really should clarify and flesh out the question and explain what you are trying to do.

In some ways, an ASP.NET textbox is an HTML text field that C# code can make use of. So what's the problem with an ASP.NET textbox?


You can create an instance of a HtmlInput control in code, or alternatively add a runat="server" attribute to an <input> element in your aspx file, you can then access this from server-side code using it's ID.

As an alternative, you may wish to take a look at http://asp.net/mvc to get better control of your HTML markup.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜