Ajaxpro instance usage

Source: Internet
Author: User

Step 1:

Add the method to load on the page: ajaxpro. Utility. registertypeforajax (typeof (xc_web.frame.detectionmanager.detectreport ));

Step 2:

In the page backgroundCodeWrite ajaxpro method:

# Region determine whether the detection report has an attachment
[Ajaxpro. ajaxmethod]
Public int32 ifexist (int32 deteid)
{
T_dc_dectreport prot = new t_dc_dectreport ();
Prot. detect_id = deteid;
VaR result = Prot. getservice (). getobjectlist <t_dc_dectreport> ();
Return result. count;
}
# Endregion

Obtain the parameter value in the background:

Hiddendeteid. value = request. querystring ["deteid"]. tostring ();

Note: Because the ajaxpro method does not support server-side controls, in this method, parameters must be input from the foreground, and server-side controls cannot be used in the method, such as the hiddenfield control and request. querystring (), so the value obtained by this method also needs to be determined in the background!

Step 3: foreground operations

1: Get the value of the ajaxpro method parameter

<SCRIPT type = "text/JavaScript" Language = "JavaScript">
VaR checkform = function (){
VaR deteid = $ ("# hiddendeteid"). Val ();---------- Obtain the parameter value using jquery
VaR result = xc_web.frame.detectionmanager.detectreport.ifexist (deteid). value ;----- The foreground calls the background ajaxprod method and obtains the returned value!
If (result <= 0 ){---------- Return value judgment in the previous console, because a container is required in the background to store the judgment value, but ajaxpro does not support server-side controls, so it is impossible to find a suitable control for storage.
VaR filevalue = $ ("input [name = 'affixname']"). Val ();
If (filevalue = "" | filevalue = NULL ){
Top. Dialog. Alert ("Please select a file before saving ");
Return false;
}
}
Return true;
}
</SCRIPT>

 

2: Call the front-end JavaScript Method

onclientclick =" Return checkform (); " cssclass =" bluebuttoncss "onclick =" btnsubmit_click "/>

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.