Click here to Skip to main content
11,410,584 members (58,837 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET HTML
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:
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 16-May-11 23:10pm
Edited 16-May-11 23:41pm
v2
Comments
SAKryukov at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
=======================================================
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. Smile | :)
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
ankitmahesh91186 at 14-Nov-11 6:37am
   
I also having the same issue.. plz help
thatraja at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 8,755
1 OriginalGriff 6,915
2 Maciej Los 3,390
3 Abhinav S 3,248
4 Peter Leow 3,059


Advertise | Privacy | Mobile
Web01 | 2.8.150414.5 | Last Updated 21 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100