System.Web.UI.Page currentPage = HttpContext.Current.Handler as System.Web.UI.Page; System.Web.UI.PageInfo currentPageInfo = currentPage.Current;
System.Web.UI.WebControls.TextBox textBox = new System.Web.UI.WebControls.TextBox(); textBox.ID = "TextBox1"; textBox.Text = "Hello, World!"; textBox.RenderControl(new System.IO.StringWriter());In this example, we create an instance of the System.Web.UI.WebControls.TextBox class and set its ID and Text property. We then call the RenderControl method and pass an instance of the System.IO.StringWriter class to render the control to a string. Package/Library: The System.Web.UI.WebControls namespace is a part of the System.Web assembly, which is a part of the .Net Framework's Base Class Library (BCL).