为什么你不能有多个服务器端表单标签页? [英] Why you can't have a page with multiple server-side Form tags?

查看:113
本文介绍了为什么你不能有多个服务器端表单标签页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道为什么asp.net不允许这样做?页数很多的包含超过1的形式,登录 - 注册表格,搜索 - 其他形式等等...

I wonder why asp.net doesn't allow this? Lot's of pages contain more than 1 form, Login - Register forms, search - other forms and so on...

所以我的猜测是,我可以一式细OOP asp.net对象和其他与纯HTML关联,我必须处理响应从这320交织在两个完整的独立的方式。是这样吗?

So My guess is I can associate one form with fine oop asp.net objects and other with plain html and I have to handle the response from these froms in two complete seperate ways. Is that right?

请解释一下这是怎么回事就在这里,为什么asp.net不允许这种

Please explain what's going on here, and why asp.net doesn't allow this

推荐答案

ASP.NET web表单依赖于有一个单一的服务器端的形式。

ASP.NET webforms relies on having a single server side form.

你想要的(没有 =服务器属性),您可以添加尽可能多的客户端的形式。

You can add as many client side forms as you want (no runat="server" attribute).

这是由于企图有像web开发发展模式的桌面。

This is due to the attempt to have a desktop like development model for web development.

请参阅了解原因MSDN杂志的一篇文章:

See this MSDN magazine article for more reasons:

单表单模型是针对ASP.NET状态维护功能的实现的关键因素。由于页总是发送到自身,运行时发现它方便地检索并恢复上次访问期间保存的状态。虽然有其他的方式来保存和恢复页面的状态,使用单表单模型是目前最简单,最有效的所有解决方案中。

The single-form model is a key element for the implementation of the ASP.NET state maintenance feature. Since the page always posts to itself, the runtime finds it easy to retrieve and restore the state saved during the last access. While there are other ways to save and restore the state of a page, using a single-form model is by far the simplest and most effective of all solutions.

在一般情况下,放弃多种形式不是一个很大的牺牲。多种形式有时是有用的,但可能不会那样频繁,你可能认为。在其中,你会发现它有助于使用多种形式的情形是:当你在一个大量的页面的搜索和登录对话框中实现基于表单的功能,例如。我会回到这个以后在列。在继续之前,虽然,HtmlForm控件类的审查是为了。

In general, renouncing multiple forms is not a big sacrifice. Multiple forms are sometimes useful, but probably not as frequently as you may think. A scenario in which you would find it helpful to use multiple forms is when you implement form-based functionality in a large number of pages—in search and login dialogs, for example. I'll return to this later in the column. Before going any further, though, a review of the HtmlForm class is in order.

请注意:

与ASP.NET MVC有没有这样的限制 - 你可以有很多形式,只要你喜欢

ASP.NET-MVC has no such limitation - you can have as many forms as you like.

这篇关于为什么你不能有多个服务器端表单标签页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆