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 "/>