Summary of using Ajax technology in DOTNET

Source: Internet
Author: User
Tags dotnet

Because there is a free Ajax engine available in DOTNET, this hot technology is not far away. The following is an example of how to use the common ajaxpro. dll and Ajax. dll:
1. Add configuration information to the Web. config file.
<System. Web>
<Globalization requestencoding = "UTF-8" responseencoding = "UTF-8"/>
<Httphandlers>
<Add verb = "post, get" Path = "ajaxpro/*. ashx" type = "ajaxpro. ajaxhandlerfactory, ajaxpro"/>
</Httphandlers>
...
</System. Web>
2. register the background code class in the pageload event:
Public partial class meetingmanage_newmeeting: system. Web. UI. Page
{
Protected void page_load (Object sender, eventargs E)
{
Ajaxpro. Utility. registertypeforajax (typeof (meetingmanage_newmeeting ));
...
}
...
}
3. register the method to be called on the client in the background code class: note that this method must be declared as public. Otherwise, if protected or private is used, the method cannot be accessed at the front end.
// Delete the meeting material attachment
[Ajaxpro. ajaxmethod]
Public String delmeetingdata (string filepath)
{
Try
{
If (filepath! = "")
File. Delete (server. mappath (filepath ));
Return "true ";
}
Catch (exception ex)
{
Return "false ";
}
}

4. Call the method in the background code class in the page file.
// Delete the uploaded file
Function delfile (lstid)
{
VaR lstfile = Document. getelementbyid (lstid );
For (VAR I = 0; I <lstfile. Options. length; I ++)
{
If (lstfile. Options [I]. Selected)
{
VaR strvalue = lstfile. Options [I]. value;
VaR strarray = strvalue. Split (",");
VaR strdelfile = strarray [2] + strarray [0];
VaR result = meetingmanage_newmeeting.delmeetingdata (strdelfile). value;
If (result = "true ")
Alert ("File deleted successfully! ");
Lstfile. Options. Remove (I );
}
}
}

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.