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