InnerHtml of div is always empty

232 views Asked by At

I have next html :

<div class="output">
    <div id="divInternet" runat="server" class="issue">
        <!--This message shows up regardless of choice-->
        <p>
            If you operate a service that connects to the internet and intend to collect any...
        </p>
    </div>
</div>

On Server side i try to get InnerHTML of div with id divInternet:

var q1Text = divInternet.InnerHtml;

but always q1Text is empty.

I try to add attribute runat="server" to inner p but it throws exception that innerHTML must be literal.


Expected result - i want to get <p> and its content:

<p>
    If you operate a service that connects to the internet and intend to collect any...
</p>

What have i missed?


UPD: i didn't mention on this from start, but now i think it is important.

More detailer content of div :

<p>
    If you operate a service that connects to the internet and intend to collect any 
    <a href= "<%=Project.Core.Common.PublisherConfigurationManager.Navigation%>privacy/faq.aspx#16" target="_blank" class="dotlink">personal information</a>...
</p>

So there are tag a that contains data from config.

1

There are 1 answers

2
Mukesh Kalgude On

try this

var q1Text = new StringBuilder();
    divInternet.RenderControl(new HtmlTextWriter(new StringWriter(q1Text)));