Click here to Skip to main content
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 22:10pm
Edited 16-May-11 22: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 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)
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

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

  Print Answers RSS
0 OriginalGriff 255
1 Sergey Alexandrovich Kryukov 104
2 Richard MacCutchan 100
3 kbrandwijk 75
4 Vinay Mistry 70
0 Sergey Alexandrovich Kryukov 9,040
1 OriginalGriff 8,121
2 CPallini 2,613
3 Richard MacCutchan 2,221
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web03 | 2.8.140827.1 | Last Updated 21 Nov 2012
Copyright © CodeProject, 1999-2014
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