我们可以用多种形式的网页? [英] Can we use multiple forms in a web page?
问题描述
到目前为止,所有的网页,我遇到最多包含一个<形式为GT;
标记。为什么不能多的人?我想不出原因多种形式不能在同一网页中共存。
So far, all the web pages I met contain at most one <form>
tag. Why not multiple ones? I can not think of reasons why multiple forms can't coexist within the same web page.
此外,具体到ASP.NET - 为什么所有的服务器控件都放在&LT内;形式&GT;
标记?为什么不把它们别的地方?
Also, to be specific to ASP.NET - why are all the server controls are placed within the <form>
tag? Why not place them somewhere else?
另外,
我注意到,在的.aspx
文件中的&LT;形式&GT;
标签的 RUNAT =服务器的属性,而普通的服务器控件,如按钮
也有一个。因此,似乎在&LT;形式为GT;
也有服务器控件。但奇怪的是,我无法找到它的Visual Studio工具箱。
I noticed that in an .aspx
file, the <form>
tag has the runat=server attribute, while a normal server control such as Button
also has one. So it seems the <form>
is also a server control. But strangely enough, I cannot find it in the Visual Studio Toolbox.
推荐答案
有可能是多种形式,<一个href=\"http://www.frederikvig.com/2009/06/using-multiple-forms-on-an-asp-net-web-forms-page/\">with <一href=\"http://stackoverflow.com/questions/91350/multiple-forms-on-asp-net-page/91374#91374\">hacks.
There can be multiple forms, with hacks.
这的确是一个缺点的WebForms的。在ASP.NET MVC,只要你想,你可以实现尽可能多的形式(它是有效的和放大器;网页的正确的行为)。
It is indeed a shortcoming of WebForms. In ASP.NET MVC you can implement as many forms as you want (and it is valid & correct behavior of web pages).
原因所有的服务器控件都放在里面的&LT;形式为GT;
标签是允许的WebForms引擎识别它们,载入他们的价值观和放大器;自/至ViewState中保存其值。几乎所有的基础设施的WebForms控制管理是基于标签包含您从code-后面访问一切的想法。
The reason all server controls are placed inside <form>
tag is to allow the WebForms engine to recognize them, load their values & save their values from/to the ViewState. Almost all infrastructure of control management in WebForms is based on the idea that a tag contains everything you access from the code-behind.
这篇关于我们可以用多种形式的网页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!