In the page load, the response is sent to the page. When the
page is loaded the generated HTML is directly binded to the DIV using the
innerHTML property (see the code below).
Listing 13
dvContent.InnerHtml = PopulateGrid(dt.DefaultView, intPage, intRowsPerPage)
dvPager.InnerHtml = Pager(dt.Rows.Count, intPage, intRowsPerPage, intPageSet)
If the Parameters are received through the querystring, that
is it is an AJAX call, the Response XML is generated and sent back to the
client. Note I have used <![CDATA[ ]]>. Since if you directly embed html
within XML tags, the XML structure will be broken meaning if you place it
within these tags, the Parser ignores it.
Listing 14
Dim strResults As String = PopulateGrid(dt.DefaultView, intPage, intRowsPerPage)
Dim strPager As String = Pager(dt.Rows.Count, intPage, intRowsPerPage, intPageSet)
Dim strResponse As StringBuilder = New StringBuilder
strResponse.Append("<RESPONSE><VALUES><ERROR>False</ERROR><PAGER><![CDATA[")
strResponse.Append(strPager)
strResponse.Append("]]></PAGER><GRID><![CDATA[")
strResponse.Append(strResults)
strResponse.Append("]]></GRID></VALUES></RESPONSE>")
Response.Clear()
Response.ContentType = "text/xml"
Response.Write(strResponse.ToString())
Response.End()