|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
namespace jQueryFiveAjaxCalls.StudentRecordArchive
{
public partial class StudentRecordsHTMLFragment : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
String ReturnJson = Request.QueryString["RETURNJSON"];
String NoOfRecordsToRetrieve = Request.QueryString["NRECORD"];
if (NoOfRecordsToRetrieve == null)
{
NoOfRecordsToRetrieve = Request.Form["NRECORD"];
}
StudentRecords Records = new StudentRecords(System.Convert.ToInt16(NoOfRecordsToRetrieve));
DataGrid DG = new DataGrid();
DG.CellPadding = 14;
DG.Style.Add("font-size", "10px");
DG.HeaderStyle.BackColor = System.Drawing.Color.Brown;
DG.HeaderStyle.ForeColor = System.Drawing.Color.White;
DG.HeaderStyle.Font.Bold = true;
DG.Attributes.Add("bordercolor", "black");
DG.DataSource = Records;
DG.DataBind();
StringBuilder SB = new StringBuilder();
HtmlTextWriter TW = new HtmlTextWriter(new System.IO.StringWriter(SB));
DG.RenderControl(TW);
string ContentType = "text/html";
string Content = SB.ToString();
if (ReturnJson == "True")
{
ContentType = "text/x-json";
StringBuilder JsonSB = new StringBuilder();
JsonSB.Append("{\"TB\": \"");
JsonSB.Append(SB.Replace("\"", "'").Replace("\t", "").Replace("\r", "").Replace("\n", ""));
JsonSB.Append("\"}");
Content = JsonSB.ToString();
}
Response.ContentType = ContentType;
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
Response.OutputStream.Write(encoding.GetBytes(Content), 0, Content.Length);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I have been working in the IT industry for some time. It is still exciting and I am still learning. I am a happy and honest person, and I want to be your friend.