0

Is there a way to write pure HTML when i'm developing my ServerControl in ASP.NET?

I want to create my control as .dll file. But when I'm writing my control I can only add HTML tags and attributes in C# in my .cs file.

And so i am forced to use this in my RenderContents() method:

output.RenderBeginTag(...
output.AddAttribute(...
output.RenderEndTag(...

instead of for example:

<div attribute1="value"></div>

is there a workaround of this problem?

1 Answer 1

2

Unfortunately only user controls (ASCX) allow for this type of approach (delcarative markup) but they cannot be packaged into DLLs. I've always hated this restriction, to me it's a code smell programmatically generating markup, but this is what we must live with!

If you have very static markup you could always put it into a resource file (resx) instead of outputting the HTML programmatically

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.