Using AJAX to implement no flush binding with the data island

Source: Internet
Author: User
Tags abstract add flush generator html page net string table name
ajax| Data | refresh | No refresh the first thing we're going to use today is Ajax.NET Professional, you can get information about ajax.net from http://www.schwarz-interactive.de/. Second, you need to know the relevant knowledge of XML data island. Let's take a look at a simple binding example:

The first step is to first determine the XML data source



John Smith
Visual Notepad
Reference
specifies a data island


John Smith2
Visual Notepad2
Reference2
specifies a data island2


John Smith3
Visual Notepad3
Reference3
specifies a data island3



The second step is to determine the binding container, where we use the table








loading ... loading ... loading ... loading ...

Take these two pieces of code copy to your HTML page to run both to see the effect.

The first segment is our XML data source, which is the data to bind, the metadata node equals the table name, AUTHOR, generator, pagetype, and abstract are equivalent to the column name, and the following table is the container for displaying the data. loading ... The








The second step is to write the code that returns the dataset:

public class MyClass
{
[Ajaxmethod]
public string GetDataSet ()
{
DataSet DST = new DataSet ();
DataTable dt = new DataTable ();
Dt. Columns.Add ("Text");
Dt. Columns.Add ("number");
Random Random = new Random (Guid.NewGuid (). GetHashCode ());
for (int i = 0; I random. Next (10,20); i++)
{
DataRow row = dt. NewRow ();
row["Text"] = Guid.NewGuid (). ToString ("N");
row["number"] = random. Next (100);
Dt. Rows.Add (row);
}
Dst. Tables.add (DT);
String text = "";
using (MemoryStream ms = new MemoryStream ())
{
Dst. WriteXml (MS);
Ms. Position = 0;
StreamReader sr = new StreamReader (MS);
Text = Sr. ReadToEnd ();
}
return text;
}
}
Step Three: Register the method in Page_Load, AjaxPro.Utility.RegisterTypeForAjax (typeof (Webtest1.ajaxtest1)) (WebTest1 is the name of the namespace)

Step Fourth: Add client Bindings


is the data source for the specified TABLE, bound field name. All right, I'll see how this can be done with Ajax to achieve no flush binding. Step One: Configure Ajax to add a configuration section to the Web.config file:










name Age
Fifth step: Edit the JavaScript code to load data

Function callback (RES)
{
if (!res.error)
{
Document.all.oDataPanel.innerHTML = ' ';
}
Else
{
alert (res.error.Message);
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.