All,
I figured out the code (right after if(xmlHttp.status == 200)). My earlier problem was a null reference to the div tage 'show' only in IE, but it worked in FireFox.
The app works like:
If the number isn't unique via a database SQL count(*), it'll tell you so, but then if you enter another number (which is in fact distinct), then the user gets the message right underneath the previous {div id=show} message...it's not replaced....just appended! I'd like to have it replace the value, rather than stick the new message underneath.
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="AjaxTesting.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content=" name="vs_targetSchema">
<!-- Start script -->
<script language="javascript">
var xmlHttp = createXmlHttpRequestObject();
function createXmlHttpRequestObject()
{
var xmlHttp;
if(window.ActiveXObject)
{
try
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
xmlHttp = false;
}
}
else
{
try
{
xmlHttp = new XMLHttpRequest();
}
catch (e)
{
xmlHttp = false;
}
}
if (!xmlHttp)
{
alert("Error creating the XMLHttpRequest object.");
}
else
{
return xmlHttp;
}
}
function process()
{
varWBS = encodeURIComponent(document.getElementById("TextBox1").value);
xmlHttp.open("GET", "test.aspx?WBS=" + varWBS);
xmlHttp.onreadystatechange = handleServerResponse;
xmlHttp.send(null);
}
function handleServerResponse()
{
//if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
//{
// document.getElementById("show").innerHTML = xmlHttp.responseText;
//}
//}
//New code
if (xmlHttp.readyState == 4)
{
if(xmlHttp.status == 200)
{
var parentElement = document.getElementById('show');
var wrappingDiv = document.createElement('div');
wrappingDiv.innerHTML = xmlHttp.responseText;
parentElement.appendChild(wrappingDiv);
//document.getElementById("show").innerHTML = xmlHttp.responseText;
//document.all[show].innerHTML = xmlHttp.responseText;
}
else
{
alert("hmmmm");
}
}
}
//End code
</script>
<!-- End script -->
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<table id="maintbl" border="1">
<tr>
<td><asp:textbox id="TextBox1" onblur="process()" style="Z-INDEX: 101" runat="server"></asp:textbox></td>
<td><asp:textbox id="TextBox2" style="Z-INDEX: 101" runat="server"></asp:textbox></td>
</tr>
<tr>
<td>
<div id="show"></div>
</td>
</tr>
</table>
</form>
</body>
</HTML>
I figured out the code (right after if(xmlHttp.status == 200)). My earlier problem was a null reference to the div tage 'show' only in IE, but it worked in FireFox.
The app works like:
If the number isn't unique via a database SQL count(*), it'll tell you so, but then if you enter another number (which is in fact distinct), then the user gets the message right underneath the previous {div id=show} message...it's not replaced....just appended! I'd like to have it replace the value, rather than stick the new message underneath.
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="AjaxTesting.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content=" name="vs_targetSchema">
<!-- Start script -->
<script language="javascript">
var xmlHttp = createXmlHttpRequestObject();
function createXmlHttpRequestObject()
{
var xmlHttp;
if(window.ActiveXObject)
{
try
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
xmlHttp = false;
}
}
else
{
try
{
xmlHttp = new XMLHttpRequest();
}
catch (e)
{
xmlHttp = false;
}
}
if (!xmlHttp)
{
alert("Error creating the XMLHttpRequest object.");
}
else
{
return xmlHttp;
}
}
function process()
{
varWBS = encodeURIComponent(document.getElementById("TextBox1").value);
xmlHttp.open("GET", "test.aspx?WBS=" + varWBS);
xmlHttp.onreadystatechange = handleServerResponse;
xmlHttp.send(null);
}
function handleServerResponse()
{
//if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
//{
// document.getElementById("show").innerHTML = xmlHttp.responseText;
//}
//}
//New code
if (xmlHttp.readyState == 4)
{
if(xmlHttp.status == 200)
{
var parentElement = document.getElementById('show');
var wrappingDiv = document.createElement('div');
wrappingDiv.innerHTML = xmlHttp.responseText;
parentElement.appendChild(wrappingDiv);
//document.getElementById("show").innerHTML = xmlHttp.responseText;
//document.all[show].innerHTML = xmlHttp.responseText;
}
else
{
alert("hmmmm");
}
}
}
//End code
</script>
<!-- End script -->
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<table id="maintbl" border="1">
<tr>
<td><asp:textbox id="TextBox1" onblur="process()" style="Z-INDEX: 101" runat="server"></asp:textbox></td>
<td><asp:textbox id="TextBox2" style="Z-INDEX: 101" runat="server"></asp:textbox></td>
</tr>
<tr>
<td>
<div id="show"></div>
</td>
</tr>
</table>
</form>
</body>
</HTML>