Click here to Skip to main content
15,940,430 members
Please Sign up or sign in to vote.
3.67/5 (3 votes)
See more:
I have written the following AJAX code for getting response from .aspx page. But getting an error htmlfile: Unknown Runtime Error for the below line in bold:
C#
function CheckCode() {
var sname = document.getElementById('<%=txtName.ClientID %>').value;
if (sname != "" || sname != null) {
request = new XMLHttpRequest();
request.onreadystatechange = function () {
if (request.readyState == 4 && request.status == 200) {
document.getElementById('<%=lblNameError.ClientID %>').innerHTML = request.responseText;
}
}
var loc = "CheckCode.aspx?name=" + sname;
request.open("GET", loc, true);
request.send();
}
in Checkcode.aspx

//..some code
if (dr.Read())
{
checkno = 0;
Response.Write("already exists");
}
else
{
checkno = 1;
Response.Write("continue");
}
Posted
Updated 16-May-11 22:41pm
v2
Comments
Sergey Alexandrovich Kryukov 17-May-11 15:53pm    
Not clear, because you need to show in which line of code it happens. You need to catch all exception and provide exception dump with stack and all inner exceptions, recursively.
--SA

When you are sendind any response using "Response.Write(........)", then it may have some previous value.
try to clear it first and then ending it.

try this
=======================================================
C#
Response.Clear();   //Add this line
if (dr.Read())
{
checkno = 0;
Response.Write("already exists");
}
else
{
checkno = 1;
Response.Write("continue");
}
Response.End();    //And add this

=======================================================
And you are good to go. :)
 
Share this answer
 
v2
 
Share this answer
 
Comments
ankitmahesh91186 14-Nov-11 6:37am    
I also having the same issue.. plz help
thatraja 14-Nov-11 6:48am    
Don't you check the link in my answer? See that for solution(s)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900