Question

Using asp .net and C# I've managed to use a HTMLTextWriter in my override Render method to render two divs. But they appear at the end of the page, how can I choose where to render these divs if I needed them to appear in a particular asp panel for example?

Thanks a lot,

Dan

EDIT: My bit of code:

    protected override void Render(HtmlTextWriter writer)
    {
        StringWriter stringWriter = new StringWriter();
        base.Render(writer);
        using (HtmlTextWriter writer2 = new HtmlTextWriter(stringWriter))
        {
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "testDiv");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);
            writer.RenderEndTag();
        }
    }
Was it helpful?

Solution

I think you´ll need to use a HTML parser like Majestic. You can render your page into a memorystream and then manipulate it as you want.

If the only problem is to customize the panel rendering, you can write a control that inherits asp:panel and inserts the desired classes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top