help regarding insertion updation of a registration form using manual ajax

Last post 11-14-2008 3:41 AM by suvo. 3 replies.

Sort Posts:

  • help regarding insertion updation of a registration form using manual ajax

    09-28-2008, 2:45 PM
    • Member
      point Member
    • suvo
    • Member since 11-14-2007, 11:09 AM
    • Posts 162

    i want to insert update delete a registration from using manual ajax.can any body help me..i dont want to use script  manager.there will be a loading picture that will be seen while insertion updation will be happening in server.

    i have to integrate the script of insert funcion.The script of the azjax function

    var xmlHttp;

    function ajaxFunction()
    {
        //var xmlHttp;
        try
        {
            xmlHttp=new XMLHttpRequest();
        }
        catch(e)
        {
            //IE
            try
            {
                xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch(e)
            {
                try
                {
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch(e)
                {
                    alert("Your browser doesnt support AJAX");
                    return null;
                }
            }
        }
        xmlHttp.onreadystatechange=statechange;
        return xmlHttp;
    }

  • Re: help regarding insertion updation of a registration form using manual ajax

    09-29-2008, 2:04 PM
    • Member
      point Member
    • suvo
    • Member since 11-14-2007, 11:09 AM
    • Posts 162

    <span id="spnBuyBtn" runat="server">

    <input type="button" id="Button1" value="insert" runat="server" onclick="ins();"/>

    <span id="spnload" style="display:none"><img src="images/buycart.gif"></span>

    function ins()

    {

    var name=document.getElementById("txtname").value;

    var address=document.getElementById("txtaddress").value;

    var spnbuy=document.getElementById("spnBuyBtn");

    var spnload=document.getElementById("spnload");

    //alert("btn: " + spnbuy + " ajax img: " + spnload);

    var xmlHttpReq_findfile = false;

    var self_findfile = this;

    if (window.XMLHttpRequest)

    {

    self_findfile.xmlHttpReq_findfile =
    new XMLHttpRequest();

    }

    else if (window.ActiveXObject)

    {

    self_findfile.xmlHttpReq_findfile =
    new ActiveXObject("Microsoft.XMLHTTP");

    }

    self_findfile.xmlHttpReq_findfile.open(
    "POST", "frmAjaxPaget.aspx", true);

    // self_findfile.xmlHttpReq_findfile.open("POST", "edit_reg.aspx", true);

     

    self_findfile.xmlHttpReq_findfile.setRequestHeader(
    "Content-Type", "application/x-www-form-urlencoded");self_findfile.xmlHttpReq_findfile.onreadystatechange = function()

    {

    if (self_findfile.xmlHttpReq_findfile.readyState == 4)

    {

    var ret= self_findfile.xmlHttpReq_findfile.responseText;

    if(ret==="t")

    {

    // alert(ret);

    spnbuy.style.display="block";

    spnload.style.display="none";

    // window.location="reg.aspx";

    }

    else

    {

    alert(
    "Some problem in adding cart!!plz try again.....");

    }

    }

    if (self_findfile.xmlHttpReq_findfile.readyState < 4)

    {

    spnbuy.style.display=
    "none";spnload.style.display="block";

    }

    }

     

    self_findfile.xmlHttpReq_findfile.send("name="+ name +"&address="+ address);

    //self_findfile.xmlHttpReq_findfile.send("proId="+ proID +"&catId="+ catId +"&mode="+Mode+"&randN="+Math.random());

    flag=true;

     

     

    }

    in form ajaxpage i have written the code for insertiion:-

     

    if (Request.Params["name"] != null && Request.Params["address"] != null)

    {

    string sql = "insert into tblregister (name,address) values('" + Convert.ToString(Request.Params["name"]) + "','" + Convert.ToString(Request.Params["address"]) + "')";

    myobj.ReturnExecute(sql);

    Response.Write(
    "t");

    }

    else

    {

    Response.Write(
    "f");

    }

    but the problem is that in the line:

    var ret= self_findfile.xmlHttpReq_findfile.responseText; is gettin every thing from the formajax page.i cannot discriminate only  t value for which the loading picture span will close and insertion will take place.Evertime the control is goin to

    alert("Some problem in adding cart!!plz try again.....");

     

    plz help

  • Re: help regarding insertion updation of a registration form using manual ajax

    11-13-2008, 3:38 AM
    • Member
      point Member
    • suvo
    • Member since 11-14-2007, 11:09 AM
    • Posts 162
    JScript File function del(id) { var objMainDiv=document.getElementById("MainPlaceHolder"); if(objMainDiv!=null) { if(id!=null) { var xmlHttpReq_Del = false; var self = this; if (window.XMLHttpRequest) { self.xmlHttpReq_Del = new XMLHttpRequest(); } else if (window.ActiveXObject) { self.xmlHttpReq_Del = new ActiveXObject("Microsoft.XMLHTTP"); } self.xmlHttpReq_Del.open('POST', "from_ajax_delete.aspx", true); self.xmlHttpReq_Del.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); self.xmlHttpReq_Del.onreadystatechange = function() { if (self.xmlHttpReq_Del.readyState == 4) { //alert(self.xmlHttpReq.responseText); document.getElementById("dvAjaxPic").style.display="none"; objMainDiv.style.display="block"; var GetValue=new Array(); if(self.xmlHttpReq_Del.responseText.indexOf('~' != -1)) { GetValue=self.xmlHttpReq_Del.responseText.split("~"); } if(GetValue[0].toString()!="") { if(GetValue[0].toString()=="0") { } else { objMainDiv.innerHTML=GetValue[2].toString(); } } else { alert("Ajax return not found..."); } } else { document.getElementById("dvAjaxPic").style.display="block"; objMainDiv.style.display="none"; } } self.xmlHttpReq_Del.send("mode=3&id="+id); } else { alert("Invalid parameter. Try again."); } } else { alert("Objects not found. Try again."); } } function LoadResponse(response,control) { var container=document.getElementById("dvTest"); try { while(container.firstChild) container.removeChild(container.firstChild); var t=document.createElement('div'); t.innerHTML=response; container.appendChild(t); } catch(ex) { container.innerHTML=response; } } function loadGV() { var xmlHttpReq = false; var self = this; if (window.XMLHttpRequest) { self.xmlHttpReq = new XMLHttpRequest(); } else if (window.ActiveXObject) { self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); } self.xmlHttpReq.open('POST', "from_ajax_delete.aspx", true); self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); self.xmlHttpReq.onreadystatechange = function() { if (self.xmlHttpReq.readyState == 4) { var GetValue=new Array(); if(self.xmlHttpReq.responseText.indexOf('~' != -1)) { GetValue=self.xmlHttpReq.responseText.split("~"); } if(GetValue[0].toString()!="") { if(GetValue[0].toString()=="0") { LoadResponse(GetValue[2],"MainPlaceHolder"); } else { } } else { alert("Ajax return not found..."); } } else { } } self.xmlHttpReq.send("m=2"); } function ins() { var name=document.getElementById("txtname").value; var address=document.getElementById("txtaddress").value; var spnbuy=document.getElementById("spnBuyBtn"); var spnload=document.getElementById("spnload"); //alert("btn: " + spnbuy + " ajax img: " + spnload); var xmlHttpReq_findfile = false; var self_findfile = this; if (window.XMLHttpRequest) { self_findfile.xmlHttpReq_findfile = new XMLHttpRequest(); } else if (window.ActiveXObject) { self_findfile.xmlHttpReq_findfile = new ActiveXObject("Microsoft.XMLHTTP"); } self_findfile.xmlHttpReq_findfile.open("POST", "frmAjaxCart.aspx", true); self_findfile.xmlHttpReq_findfile.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); self_findfile.xmlHttpReq_findfile.onreadystatechange = function() { if (self_findfile.xmlHttpReq_findfile.readyState == 4) { var ret= self_findfile.xmlHttpReq_findfile.responseText; var GetValue=new Array(); GetValue=ret.split(''); // alert(GetValue[0]); // alert(GetValue[1]); if(GetValue[0]=="t") { spnbuy.style.display="block"; spnload.style.display="none"; } else { alert("Some problem in inserting!!plz try again....."); } } if (self_findfile.xmlHttpReq_findfile.readyState
  • Re: help regarding insertion updation of a registration form using manual ajax

    11-14-2008, 3:41 AM
    • Member
      point Member
    • suvo
    • Member since 11-14-2007, 11:09 AM
    • Posts 162

    i have modified the js..

    // JScript File

    function del(id)

    {

    var objMainDiv=document.getElementById("MainPlaceHolder");if(objMainDiv!=null)

    {

    if(id!=null)

    {

    var xmlHttpReq_Del = false;

    var self = this;if (window.XMLHttpRequest)

    {

    self.xmlHttpReq_Del =
    new XMLHttpRequest();

    }

    else if (window.ActiveXObject)

    {

    self.xmlHttpReq_Del =
    new ActiveXObject("Microsoft.XMLHTTP");

    }

    self.xmlHttpReq_Del.open('POST', "from_ajax_delete.aspx", true);

    self.xmlHttpReq_Del.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

     

    self.xmlHttpReq_Del.onreadystatechange =
    function()

    {

    if (self.xmlHttpReq_Del.readyState == 4)

    {

    //alert(self.xmlHttpReq.responseText);

    document.getElementById("dvAjaxPic").style.display="none";objMainDiv.style.display="block";

     

    var GetValue=new Array();

    if(self.xmlHttpReq_Del.responseText.indexOf('~' != -1))

    {

    GetValue=self.xmlHttpReq_Del.responseText.split(
    "~");

    }

    if(GetValue[0].toString()!="")

    {

    if(GetValue[0].toString()=="0")

    {

     

    }

    else

    {

    objMainDiv.innerHTML=GetValue[2].toString();

    }

    }

    else

    {

    alert(
    "Ajax return not found...");

    }

    }

    else

    {

    document.getElementById(
    "dvAjaxPic").style.display="block";objMainDiv.style.display="none";

    }

    }

    self.xmlHttpReq_Del.send(
    "mode=3&id="+id);

    }

    else

    {

    alert(
    "Invalid parameter. Try again.");

    }

    }

    else

    {

    alert(
    "Objects not found. Try again.");

    }

    }

     

    function LoadResponse(response,control)

    {

    var container=document.getElementById("dvTest");

    try

    {

    while(container.firstChild)

    container.removeChild(container.firstChild);

    var t=document.createElement('div');

    t.innerHTML=response;

    container.appendChild(t);

    }

    catch(ex)

    {

    container.innerHTML=response;

    }

    }

     

     

     

    function loadGV()

    {

     

    var xmlHttpReq = false;

    var self = this;

    if (window.XMLHttpRequest)

    {

    self.xmlHttpReq =
    new XMLHttpRequest();

    }

    else if (window.ActiveXObject)

    {

    self.xmlHttpReq =
    new ActiveXObject("Microsoft.XMLHTTP");

    }

    self.xmlHttpReq.open(
    'POST', "from_ajax_delete.aspx", true);

    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

    self.xmlHttpReq.onreadystatechange = function()

    {

    if (self.xmlHttpReq.readyState == 4)

    {

    var GetValue=new Array(); if(self.xmlHttpReq.responseText.indexOf('~' != -1))

    {

    GetValue=self.xmlHttpReq.responseText.split(
    "~");

    }

    if(GetValue[0].toString()!="")

    {

    if(GetValue[0].toString()=="0")

    {

    LoadResponse(GetValue[2],
    "MainPlaceHolder");

    }

    else

    {

     

    }

    }

    else

    {

    alert(
    "Ajax return not found...");

    }

    }

    else

    {

    }

    }

     

    self.xmlHttpReq.send(
    "m=2");

    }

     

    function ins()

    {

    var name=document.getElementById("txtname").value;

    var address=document.getElementById("txtaddress").value;

    var spnbuy=document.getElementById("spnBuyBtn");

    var spnload=document.getElementById("spnload");

    //alert("btn: " + spnbuy + " ajax img: " + spnload);

    var xmlHttpReq_findfile = false;

    var self_findfile = this;

    if (window.XMLHttpRequest)

    {

    self_findfile.xmlHttpReq_findfile =
    new XMLHttpRequest();

    }

    else if (window.ActiveXObject)

    {

    self_findfile.xmlHttpReq_findfile =
    new ActiveXObject("Microsoft.XMLHTTP");

    }

    self_findfile.xmlHttpReq_findfile.open(
    "POST", "frmAjaxCart.aspx", true);

     

    self_findfile.xmlHttpReq_findfile.setRequestHeader(
    "Content-Type", "application/x-www-form-urlencoded");self_findfile.xmlHttpReq_findfile.onreadystatechange = function()

    {

    if (self_findfile.xmlHttpReq_findfile.readyState == 4)

    {

    var ret= self_findfile.xmlHttpReq_findfile.responseText;

     

    var GetValue=new Array();

    GetValue=ret.split('');

    // alert(GetValue[0]);

    // alert(GetValue[1]);

    if(GetValue[0]=="t")

    {

    spnbuy.style.display=
    "block";spnload.style.display="none";

    }

    else

    {

    alert(
    "Some problem in inserting!!plz try again.....");

    }

    }

    if (self_findfile.xmlHttpReq_findfile.readyState < 4)

    {

    spnbuy.style.display=
    "none";spnload.style.display="block";

    }

    }

     

    self_findfile.xmlHttpReq_findfile.send(
    "name="+ name +"&address="+ address); flag=true;

     

     

    }

     

Page 1 of 1 (4 items)