Nested GridView problem when posting the data using XmlHttpRequest object

Last post 10-15-2008 9:10 AM by sarathc2000. 1 replies.

Sort Posts:

  • Nested GridView problem when posting the data using XmlHttpRequest object

    10-07-2008, 10:42 AM
    • Member
      5 point Member
    • sarathc2000
    • Member since 06-11-2007, 11:13 PM
    • Posts 18

    Hi Pals,

     
        I have one new requirement which i had not done so far.The Requirement is "I need to save the page entire data for every five minutes without a postback".
    The page can contains the Nested Grid views and some complex data container controls. The Approach that i am following is using the XMLHttpRequestobject, i am positing the Data back to the server. before posting the data back to the sever, i am Generating the Data to be posted back as below.
     

    var theData = '';
      var theform = document.forms[0];
      var thePage = window.location.pathname + window.location.search +'?isCallBack='+queryString;
      var eName = '';
      if(eventTarget)
      theData  = '__EVENTTARGET='  + escape(eventTarget.split("$").join(":")) + '&';
      theData += '__EVENTARGUMENT=' + eventArgument + '&';
      theData += '__VIEWSTATE=' + escape(theform.__VIEWSTATE.value).replace(new RegExp('\\+', 'g'), '%2b') + '&';
      theData += 'IsCallBack=true&';
      for( var i=0; i<theform.elements.length; i++ )
      {
        eName = theform.elements[i].name;
       if( eName == '__EVENTTARGET' || eName == '__EVENTARGUMENT' || eName == '__VIEWSTATE' ||eName == '__SCROLLPOSITIONX'||eName == '__SCROLLPOSITIONY'||eName == '__VIEWSTATEENCRYPTED')
        {
          // Do Nothing
        }
        else if(eName == '__EVENTVALIDATION')
        {
            theData += '__EVENTVALIDATION=' + escape(theform.__EVENTVALIDATION.value.split("$").join(":")).replace(new RegExp('\\+', 'g'), '%2b') + '&';
        }
        else
        {
          if(theform.elements[i].type.toString()=="checkbox")
          {
            if(theform.elements[i].checked)
            {
            theData = theData + escape(eName.split("$").join(":")) + '=checked';
            }
            else
            {
            theData = theData + escape(eName.split("$").join(":")) + '=';
            }
            theData = theData + '&';
          }
          else
          {
            theData = theData + escape(eName.split("$").join(":")) + '=' + theform.elements[i].value;
            theData = theData + '&';
          }
        }
      }
      theData+='__SCROLLPOSITIONX=0&';
      theData+='__SCROLLPOSITIONY=244&';
      theData+='__VIEWSTATEENCRYPTED= &';

     

    Once that is completed i am posting the data to the server as below.

     if(this.XmlHttp)
      {
        if( this.XmlHttp.readyState == 4 || this.XmlHttp.readyState == 0 )
        {
          var oThis = this;
          this.XmlHttp.open('POST', thePage, true);
          this.XmlHttp.onreadystatechange = function()
                                            { oThis.ReadyStateChange(); };
          this.XmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
          this.XmlHttp.send(theData);
          
        }
      }

     

    This will Asynchronously call the Page_Load event. There i am able to get all the modified data of controls.But i had the Nested Grid View in the page, Inthe inner grid view , i had a check box. i am not able to find the control value.

    can any one please help me out in solving this.
     

    sar
  • Re: Nested GridView problem when posting the data using XmlHttpRequest object

    10-15-2008, 9:10 AM
    Answer
    • Member
      5 point Member
    • sarathc2000
    • Member since 06-11-2007, 11:13 PM
    • Posts 18

     hi guys,

                After a long R&D i got the solution for that.There is no necesity of encrypting the Controls inside the Grid.

    For the controls in the grid instead of the below code

     if(theform.elements[i].type.toString()=="checkbox")
          {
            if(theform.elements[i].checked)
            {
            theData = theData + escape(eName.split("$").join(":")) + '=checked';
            }
            else
            {
            theData = theData + escape(eName.split("$").join(":")) + '=';
            }
            theData = theData + '&';
          }

    place 

    if(theform.elements[i].type.toString()=="checkbox")
          {
            if(theform.elements[i].checked)
            {
            theData = theData +eName + '=checked';
            }
            else
            {
            theData = theData + eName+ '=';
            }
            theData = theData + '&';
          }

     

    But now i got a new problem. the radio buttons in the page are not maintaining their values.Please help me out

    sar
Page 1 of 1 (2 items)