asp.net.netformsrunatserverrunat

Can the code within a <script runat=server> read form values which are posted by a form which doesn't have runat=server attribute?


I want to post a form on html and process the variables with asp.net code, like writing a php code. do I have to use <% %> or can I create an empty file with

<script runat=server>

</script>

Solution

  • You just need to get the postback values using the Request.Form.

    This exposes all the input values in properties.

    Look at this:

    HttpRequest.Form

    If you have an iput with id "name", you can read the user input like so:

      Request.Form["name"]
    

    The result is always a string, so that you'll need to parse it to convert it to another data type.