I have included a div in my web page using HtmlGenericControl. With a button click , i want to add text inside the div using HttpContext. I don't want to use InnerHtml because the browser hangs when the text i want to include is very long. I tried the following way but it prints the text outside the div. Please Help. Thanks!
public partial class TextViewer : System.Web.UI.Page
{
public HttpContext ctx;
protected void Page_Load(object sender, EventArgs e)
{
HtmlGenericControl myDiv = new HtmlGenericControl("div");
myDiv.Style.Add(HtmlTextWriterStyle.BackgroundColor, "Blue");
this.Controls.Add(myDiv);
ctx = this.Context;
}
protected void Button1_Click(object sender, EventArgs e)
{
ctx.Response.Write("supposed to be printed inside myDiv.");
}
}
You can write to the
HttpContextfrom code behind and access its value from jQuery.Code behind:
.ASPX: