c# - How to get Generated Html form HtmlGenericControl -
i have template html page, , need add contents dynamically in asp.net. need make many instences of template page, depending in data.
its obvious creating large html using strings dirty way. choosed generate html using htmlgenericcontrol. , made it. i cant generated html string it.
its simple add these controls in asp.net pages , rendered, need html.
if not possible, there other structrued way of generating html...???
trick told @bartdude worked charm...
for other peoples, solution goes in way...
// create generic controls htmlgenericcontrol maindiv = new htmlgenericcontrol("div"); // setting required attributes , properties // adding more generic controls // finally, html when ready stringbuilder generatedhtml = new stringbuilder(); using (var htmlstringwriter = new stringwriter(generatedhtml)) { using(var htmltextwriter = new htmltextwriter(htmlstringwriter)) { maindiv.rendercontrol(htmltextwriter); output = generatedhtml.tostring(); } }
hope helps coming readers...:)
Comments
Post a Comment