Getting the executed output of an aspx page after a short delay

Posted by Ankur on Stack Overflow See other posts from Stack Overflow or by Ankur
Published on 2009-10-21T14:27:52Z Indexed on 2010/03/30 13:23 UTC
Read the original article Hit count: 401

Filed under:
|
|
|
|

Hi all,

I have an aspx page which has some javascript code like

<script>
    setTimeout("document.write('" + place.address + "');",1);
</script>

As it is clear from the code it will going to write something on the page after a very short delay of 1 ms. I have created an another page to get the page executed by some query string and get its output. The problem is

  1. I can not avoid the delay as simply writing document.write(place.address); will not print anything as it takes a little time to get values so if i set it in setTimeout for delayed output of 1 ms it always return me a value
  2. If I request the output from another page using

    System.Net.WebClient wc = new System.Net.WebClient(); System.IO.StreamReader sr = new System.IO.StreamReader(wc.OpenRead("http://localhost:4859/Default.aspx?lat=" + lat + "&lng=" + lng)); string strData = sr.ReadToEnd();

I get the source code of the document instead of the desired output

can anyone help me out for either avoiding that delay or else delayed the client request ouput so that i get a desired value not the source code

The js on default.aspx is

<script type="text/javascript">


    var geocoder;
    var address;

    function initialize() {

      geocoder = new GClientGeocoder();
      var qs=new Querystring();
      if(qs.get("lat") && qs.get("lng"))
      {

    	geocoder.getLocations(new GLatLng(qs.get("lat"),qs.get("lng")),showAddress);
      }
      else
      {

      document.write("Invalid Access Or Not valid lat long is provided.");
      }
    }

    function getAddress(overlay, latlng) {
      if (latlng != null) {
        address = latlng;
        geocoder.getLocations(latlng, showAddress);
      }
    }

    function showAddress(r) {

        place = r.Placemark[0];

setTimeout("document.write('" + place.address + "');",1);
//document.write(place.address);

      }



    </script>

and the code on requestClient.aspx is as

System.Net.WebClient wc = new System.Net.WebClient();
    				System.IO.StreamReader sr = new System.IO.StreamReader(wc.OpenRead("http://localhost:4859/Default.aspx?lat=" + lat + "&lng=" + lng));

    				string strData = sr.ReadToEnd();

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about c#