-1

I have 2 textboxes and 1 submit button in my asp.net webform. Those controls are purely HTML controls and I don't want to use runat="server" property.

Now, when the user clicks the submit button, some action should be performed. For that where I have to write the code, and how to write the code in *.aspx.cs page.

And one more issue is, how to maintain the state of my html controls. Please clarify my doubt

4

1 回答 1

0

我不确定你的问题,但如果你想保持 HTML 表单是纯 HTML,你可以使用通用 Web 处理程序,在你的 web.config 中添加一个处理程序:

<system.webServer>
<handlers>
  <remove name="Handler Name" />
  <add name="Handler Name" verb="POST" type="Handler Name" path="/Handlerpath.ashx" />
</handlers>

HTML:

<form name="myform" method="POST" action="/Handlerpath.ashx"><input type="text" name="foo" /> </form>

创建一个类并使用IHttphandler接口作为它的基类:

class myhandler : IHttphandler{}

然后使用ProcessRequest方法获取表单数据。

        var foo = context.Request.Form["foo"];
于 2015-07-27T18:37:27.463 回答