AJAX - textbox won't change background color

I have the following default.aspx and default.aspx.cs and I cannot figure out why the textbox won't change background colors. The debugger steps through all of the server side code without error but when I get back to the webpage there is no change in color.

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Ajax C# Example</title>
    <style type="text/css">
       
    </style>
</head>
<body>
    <form autocomplete="off" id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:TextBox ID="TextBox2" runat="server" Visible=false></asp:TextBox>
    </div>
    </form>
</body>
</html>
<script language="javascript">
var net=new Object();

net.READY_STATE_UNINITIALIZED=0;
net.READY_STATE_LOADING=1;
net.READY_STATE_LOADED=2;
net.READY_STATE_INTERACTIVE=3;
net.READY_STATE_COMPLETE=4;


/*--- content loader object for cross-browser requests ---*/
net.ContentLoader=function(url,onload,onerror,method,params,contentType){
  this.req=null;
  this.onload=onload;
  this.onerror=(onerror) ? onerror : this.defaultError;
  this.loadXMLDoc(url,method,params,contentType);
}

net.ContentLoader.prototype.loadXMLDoc=function(url,method,params,contentType){
  if (!method){
    method="GET";
  }
  if (!contentType && method=="POST"){
    contentType='application/x-www-form-urlencoded';
  }
  if (window.XMLHttpRequest){
    this.req=new XMLHttpRequest();
  } else if (window.ActiveXObject){
    this.req=new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (this.req){
    try{
      var loader=this;
      this.req.onreadystatechange=function(){
        net.ContentLoader.onReadyState.call(loader);
      }
      this.req.open(method,url,true);
      if (contentType){
        this.req.setRequestHeader('Content-Type', contentType);
      }
      this.req.send(params);
    }catch (err){
      this.onerror.call(this);
    }
  }
}


net.ContentLoader.onReadyState=function(){
  var req=this.req;
  var ready=req.readyState;
  if (ready==net.READY_STATE_COMPLETE){
    var httpStatus=req.status;
    if (httpStatus==200 || httpStatus==0){
      this.onload.call(this);
    }else{
      this.onerror.call(this);
    }
  }
}

net.ContentLoader.prototype.defaultError=function(){
  alert("error fetching data!"
    +"\n\nreadyState:"+this.req.readyState
    +"\nstatus: "+this.req.status
    +"\nheaders: "+this.req.getAllResponseHeaders());
}  


function doIt(){                          
        var strValue = document.getElementById("<%=TextBox1.ClientID %>").value;                      
        var url = 'default.aspx?id=' + strValue;                              
        var strParams = strValue;                                      
        var loader1 = new                                              
        net.ContentLoader(url,FillDropDown,null,                      
                    "POST",strParams);                          
      }
      function FillDropDown(){
            //alert("returned");
        }                                                                      

</script>

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            TextBox1.Attributes.Add("onblur", "doIt()");
        }
       
        if (Request.QueryString["id"] == "Andy")
            DoIt();
    }

    public void DoIt()
    {
        TextBox1.BackColor = ColorTranslator.FromHtml("#f1f1f1");
    }
   
}
LVL 2
sutoriusAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aki4uCommented:
do you have in address path  "id=Andy" ?
e.g. "default.aspx?id=Andy"
0
sutoriusAuthor Commented:
yes, dynamically

var strValue = document.getElementById("<%=TextBox1.ClientID %>").value;                      
        var url = 'default.aspx?id=' + strValue;
0
aki4uCommented:
try this:

function doIt(){
var txtbox = document.getElementById("<%=TextBox1.ClientID %>");
if (txtbox.value=='Andy')
      txtbox.style.backgroundColor = '#f1f1f1';
}              
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

sutoriusAuthor Commented:
I am trying to change the color from the server side (c#) after the xmlhttprequest, prior to callback. You solution is aimed at the javascript.

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            TextBox1.Attributes.Add("onblur", "doIt()");
        }
       
        if (Request.QueryString["id"] == "Andy")
            DoIt();
    }

    public void DoIt()
    {
        TextBox1.BackColor = ColorTranslator.FromHtml("#f1f1f1");
    }
   
}
0
aki4uCommented:
you will not be able to because it's not a real postback.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sutoriusAuthor Commented:
Thank you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.