asmx" />
Next, you need to implement the button??™s onclick event handler, which will invoke
the web service, via its proxy, and pass it the parameters entered in the text fields. In
design view, double-click the button to create the event handler function. You will automatically
be returned to the source view and will be inside the Button1_onclick function.
Add the following code to this function:
requestValue = CarService.getCarValue(form1.txtMake.value,
form1.txtModel.value,
form1.txtYear.value,
OnComplete,
OnError);
return false;
In JavaScript, you refer to an HTML control by prefixing it with the name of the form
that it is on. In this case, the form is called form1; therefore, you can get the value of the
txtMake field using form1.txtMake.value.
To invoke a web service method via a proxy, you use the name of the web service, followed
by a period, followed by the name of the web method you want to call. You pass
parameters into the web method, and get the return value, just like for a normal function
CHAPTER 3 ?– THE MICROSOFT AJAX LIBRARY: MAKING CLIENT-SIDE JAVASCRIPT EASIER 52
call.
Pages:
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107