Getting started with ajax.net

Source: Internet
Author: User

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 );
}
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.