In. net1.1.
1. add reference to ajaxpro. dll
2. Add the configuration in <system. Web> in Web. config:
<Httphandlers>
<Add verb = "post, get" Path = "ajaxpro/*. ashx" type = "ajaxpro. ajaxhandlerfactory, ajaxpro"/>
</Httphandlers>
2.ProgramMedium:
The following example shows how to retrieve data from the database and display the data of the first cell in the table on the foreground.
Datademo. aspx. CS:
Private Void Page_load ( Object Sender, system. eventargs E)
{
Ajaxpro. Utility. registertypeforajax (Typeof(Datademo ));
}
[Ajaxpro. ajaxmethod]
Public Dataset getdataset ()
{
String Constr = " Provider = Microsoft. Jet. oledb.4.0; Data Source = " +
System. Web. httpcontext. Current. Request. physicalapplicationpath + " DB \ ajaxdemo. MDB " ;
Oledbconnection con = New Oledbconnection (constr );
Dataset DS = New Dataset ();
Oledbdataadapter da = New Oledbdataadapter ( " Select * from student " , Constr );
Da. Fill (DS );
Return DS;
}
Datademo. aspx: < Script >
Function Showdata ()
{
VaR Datasrc = Ajaxprodemo. datademo. getdataset ();
VaR Cols = Datasrc. value. Tables [ 0 ]. Columns. length;
VaR Rows = Datasrc. value. Tables [ 0 ]. Rows. length;
Alert (Cols + " Cols and " + Rows + " Rows " );
}
Function Showall ()
{
VaR Datasrc = Ajaxprodemo. datademo. getdataset ();
VaR Cell = Datasrc. value. Tables [ 0 ]. Rows [ 1 ]. Sname;
Alert (cell );
}
</ Script >
//
< Input type = " Button " Value = " Showdata " Onclick = " Showdata () " >
< Input type = " Button " Value = " Showall " Onclick = " Showall () " >
If the data source is an object array, see the followingCode:
VaR Arrstaffssearchresult = Staffselecter. searchstaffs (ssearchkeyword );
Lstunselectedstafflist. Options. Length = 0 ;
If (Arrstaffssearchresult. Value = Null | Arrstaffssearchresult. value. Length = 0 )
Return ;
For ( VaR I = 0 ; I < Arrstaffssearchresult. value. length; I ++ )
{
VaR Currstaffs = Arrstaffssearchresult. value [I];
VaR Onewitem = Document. createelement ( " Option " );
Onewitem. Value = Currstaffs. ID;
Onewitem. Text = " [ " + Currstaffs. staffno + " ] " + Currstaffs. Name;
Lstunselectedstafflist. Add (onewitem );
Lstunselectedstafflist. selectedindex = 0 ;
Currconditionallstaffsobj. Add (onewitem. Value, currstaffs );
}