如何使用asp.net从代码中分配html值

时间:2013-06-06 20:49:25

标签: html code-behind

我正在尝试从后面的代码中为div分配一个innerhtml值。这是我得到的:

private void ModalBody()
{
    LoadTemplateOverride();
    divModalBody.InnerHtml = 
}
private void LoadTemplateOverride()
{
    string templateURL = String.Format("{0}/leadgen/eodemails/templatecontroller.aspx?eodid={1}", site.Get("InternalApiUrl"), Email.ID);
    HttpWebRequest request = HttpWebRequest.Create(templateURL) as HttpWebRequest;

    HttpWebResponse response = request.GetResponse() as HttpWebResponse;

    tbSubject.Text = response.Headers["EmailSubject"];
    tbBody.Text = (new StreamReader(response.GetResponseStream())).ReadToEnd();
}

1 个答案:

答案 0 :(得分:0)

也许你可以使用Literal控件。它会将您在Text属性上放置的内容输出到呈现的HTML。

标记:

<asp:Literal ID="Literal1" runat="server"></asp:Literal>

代码背后:

Literal1.Text = "<div>Some <strong>nice</strong> HTML</div>";