How to get rid of the “default” form-element from a .aspx-page?

前端 未结 4 1645
日久生厌
日久生厌 2021-01-23 03:15

As that web-standards geek I am, I dislike the default

that surrounds my entire webpages. I\'ve seen many ASP.NET based webpages that
4条回答
  •  走了就别回头了
    2021-01-23 04:20

    If you don't need to take advantage of web controls, viewstate etc, you can code ASP.NET pages with standard HTML forms and still pick up the values the are passed back through the Request object. Similarly, you can write to the page via the Response object (explicitly or using the <%= MyVar %> format) so there's nothing to stop you having a dynamic website without . In essence, you get something rather like classic ASP in terms of the interaction with the pages/forms but you have the full .NET framework and all the usual good C#/VB.NET stuff in the back end.

    Obviously there's a question as to whether or not this is a sensible approach as you lose many of the benefits of ASP.NET (although you gain a degree of control over the output which you don't have with web controls). If you don't want to use , then MVC would seem like the best way to go. The only reason we've used the web forms model without is in migrating classic ASP apps where we wanted to get a quick port to ASP.NET and then revise the code to a more natural .NET style afterwards.

    So, with some limitations, it is entirely possible but not necessarily recommended.

    And, of course, it doesn't affect compliance with web standards at all as the runat="server" attribute is stripped out before the HTML is sent to the browser - it only appears in the source code.

提交回复
热议问题