c# - Can I Re-Use Common Html in an ASP.NET Child Control? -
i have 5 or different pieces of html in page contain same scaffolding html surrounding it, this:
//panelbase.ascx <div class="panel" id="[panel-specific-id]"> <h3>[panel-specific-header]</h3> ... [panel-specific-html] ... </h3> </div>
where panel-specific things different each panel type. there way can create common base control handle scaffolding , inherit supply panel-specific-html? panel-specific-id , panel-specific-header can pass panel directly, since panel specific html large don't want pass directly string.
or there way in each child control's ascx file:
<my:panelbase panelid="mychildpanel" header="my child's header"> // html child panel. </my:panelbase>
basically, i'm looking way reuse common portions of control don't have duplicate each child.
i guess "most proper" way of doing have main content of container template, requires type <contenttemplate></contenttemplate>
inside panels, less ideal.
if had this, i'd override addparsedsubobject, collect child controls collection , add them placeholder or similar in createchildcontrols. can done either custom control or user control (.ascx
).
for headings , whatnot, use literals , create properties wrap literal.text properties.
Comments
Post a Comment