开发者

Two form tags in one .aspx page

I'm having the following problem - I have a master page w开发者_Python百科ith an ASP menu control on it which is inherited by every content page of the web site.

The thing is that in (almost) every content page I have a form with runat = "server" and I get a compile error that I can't have 2 form tags with runat = "server" in one page (since I must put the menu control in another form tag).

How should I go about it? I'm doing this as a course project for a university course in C#/ASP.NET and it is said in the asignment that we must use master pages and we must use the asp navigation controls for the site navigation, so I can't use clear html for the menu or drop the master pages...


The first and easiest option is to remove the forms from the actual pages and use a single form for everything. ASP.NET Web Forms is designed to work that way. Since it is a university project this will be fine.

The better way is to use client side (no runat="server" form). You can handle the posts manually in a sort of "PHP fashion" by using the Request.Form object and read values off of it. This will not work if you are required to use the ASP.NET menu controls. So basically you cannot use this approach based on requirements.

P.S. Why is the post tagged with ASP.NET MVC tag? You should not have this problem if you are using ASP.NET MVC. There are other problems though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜