简体   繁体   中英

Add server controls to a page that have no form

I have A single page that has the following structure

<form runat="server"><placeholder></placeholder></form>

I have a control call 'feed' that gets added to the placeholder. The control that gets added, holds multiple other controls called 'product'.

I load the products into the feed dynamically with ajax.

The problem is, that the mark-up in the product control contains server side buttons that require a form tag with runat=server. Otherwise the page wont compile.

The page compiles fine once I add the necessary form tags to the 'product' control. This is not satisfactory as I don't want multiple form tags on the page at once.

Is there any way around this?

You can either add a single <form runat=server> that wraps all server controls or don't use server controls (normal html tags).

Or, use a more flexible framework like MVC that gives you full control of your markup.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM