Alternatives to ASCX User Control without a server-side form?

Posted by Andrew Murray on Stack Overflow See other posts from Stack Overflow or by Andrew Murray
Published on 2010-05-05T15:17:18Z Indexed on 2010/05/05 15:48 UTC
Read the original article Hit count: 237

Filed under:
|
|

I've got an ASP.NET 3.5 Web Forms application in which a large chunk of code needs to be duplicated between a few different pages. Sounds like the ideal candidate for a user-control right? Problem is, this cannot be contained within a <form runat="server"> because it contains a client-side form of it's own.

There are no runat=server controls or postbacks or anything that really need that webform - think of it just as a chunk of HTML with a few basic <% %> tags. I'd just want to set a property on the control when it's loaded, so that it knows what to output. This is purely an exercise to make the code easier to maintain.

Before I resort to using an oldskool <!--#include-->, is there some better way of doing this?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about webforms