I began playing with the Microsoft AJAX 1.0 features today with an actual project instead of simple test scenarios similar to the AJAX videos offered on the ASP.Net web site. I am using AJAX controls to make an asynchronous call to my server which in turns calls an external web service and repopulates a textarea control. The first click of the button that submits the call works perfectly. The call goes out, and in just 'sec my SOAP response is shown in the textarea without a hitch. However, this is where a big brick gets thrown through the window!
If you click the button again without refreshing the page or removing the text from the textarea, an AJAX error will be thrown in the form of an alert that states:
Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500
After the first request was sent out as a result of clicking the button, the textarea was loaded with an XML web service response. This obviously consisted of HTML characters like the "greater than" and "less than" symbols. If I attempted to send a subsequent request by clicking the button a second time WITHOUT reloading the page, the error would occur because of the HTML in the textarea. Since the textarea is located within an UpdatePanel, the text within the textarea, I am assuming the error occurs because the HTML could contain harmful content.
Dim strScript As String = "document.getElementById('" & _ Me.txtResponse.ClientID & "').value = '';"Me.cmdSubmit.Attributes.Add("onclick", strScript)
This clears out any text in the textarea before the request is actually sent from the browser to the web service. Now, I said before that this is probably not the most efficient means to do this. I only did this because it is for a test application that is testing my web service. I wouldn't do this for a production application. But this workaround may do something for you in a situation like this.
If you have the actual fix or want to tell me how horrible of a coder I am, leave some comments. :) Until next time...