一个页面可以显示两个带runat="server"的form吗?
原本打算:我的首页上有一个需要runat="server"的form,这个form用于显示detailsview。
<form id="form1" runat="server">
<div>
<asp:DetailsView ID="MessageView" runat="server">
</asp:DetailsView>
</div>
</form>
首页引用MasterPageFile为所用页面的Layout,MasterPageFile文件里面有
<form runat="server">
<asp:ScriptManager runat="server">
<Scripts>
<%--To learn more about bundling scripts in ScriptManager see http://go.microsoft.com/fwlink/?LinkID=272931&clcid=0x409 --%>
<%--Framework Scripts--%>
<asp:ScriptReference Name="MsAjaxBundle" />
<asp:ScriptReference Name="jquery" />
<asp:ScriptReference Name="jquery.ui.combined" />
<asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
<asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
<asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
<asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" />
<asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" />
<asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" />
<asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" />
<asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
<asp:ScriptReference Name="common.js" Assembly="System.Web" Path="~/Scripts/WebForms/common.js" />
<asp:ScriptReference Name="swipe.js" Assembly="System.Web" Path="~/Scripts/WebForms/swipe.js" />
<asp:ScriptReference Name="WebFormsBundle" />
<%--Site Scripts--%>
</Scripts>
</asp:ScriptManager>
如果是这样调试的话,直接报错说不能显示两个带runat="server"的form,请问有什么方法解决吗?谢谢谢。 --------------------编程问答-------------------- 那你就把第二个去掉 --------------------编程问答--------------------
MasterPageFile 母板页吗?
如果母板页有了的话内容页就不需要有了啊...
--------------------编程问答-------------------- 两个form没什么意义 一个form就可以了
如果你是想提交不同地址的话 那你会失望的
form加runat后只会提交到本页的 --------------------编程问答--------------------
你可以有多个form, 但是之能有一个 runat="server" form.
解决办法:去掉第一个,让masterpage 那个起作用好了
<div>--------------------编程问答-------------------- 不可以。可以使用ajax表单代替服务器表单。 --------------------编程问答-------------------- 你是否仔细学过“母板页”的使用方法?aspx都是通过Content来注入内容的,也就是说前边aspx里边的代码最重要嵌入后边master page内部。
<asp:DetailsView ID="MessageView" runat="server">
</asp:DetailsView>
</div>
其它的什么做法当然也不是没有,但是你最好还是先知道简单规范的东西怎么写。你可以先想想,按照你的写法,你在aspx中引用master page它能正常地将后边的内容嵌入前边里边、输出合理的html吗? --------------------编程问答-------------------- runat="server"的form 只能有一个
补充:.NET技术 , ASP.NET