Thursday, 29 November 2012

Four square venus api

Method 1:

 <form id="NewForm2" action="https://api.foursquare.com/v2/venues/search" method="Get">
     <input type="input" name="ll" value="44.3,37.2" />
    <input type="input" name="near" value="Chicago, IL" />
    <input type="input" name="oauth_token" value="Your token" />
      <input type="submit" value="Buy!"  />
 </form>

when you click Buy button it will return a json file.


Method 2:

Down Load
   Newtonsoft.Json.Compact.dll
   Newtonsoft.Json.Net35.dll.refresh
   Newtonsoft.Json.Net35.pdb
   Newtonsoft.Json.Net35.xml

Put all above files in bin folder.

Write the below code on a page:

using System;
using System.Configuration;
using System.Web;
using System.Web.UI;
using System.Collections.Generic;
using System.Data;
using System.Collections.ObjectModel;
using System.IO;
using System.Text;
using System.Runtime.Serialization.Json;
using System.Runtime.Serialization;
using System.Web.Services;
using System.Net;
using System.Drawing;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Xml;

public partial class Default4 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string url = "https://api.foursquare.com/v2/venues/search?"; //The authorization url
        string fullUrl = url + "oauth_token=yourtoken&ll=44.3,37.2&near=Chicago, IL";
        WebClient  wc = new WebClient();
        string JsonPersonalDet = wc.DownloadString(fullUrl);
        
    // converting json to xml (deserialization)
        XmlDocument xd = new XmlDocument();
        xd = (XmlDocument)JsonConvert.DeserializeXmlNode(JsonPersonalDet.ToString(), "jsonData");
        DataSet ds = new DataSet();
        ds.ReadXml(new XmlNodeReader(xd));
    }
     
}


Thursday, 8 November 2012

Clear cache of browser / PageLoad event is not working when refresh (do not find break point)

Problem due to browser cache.

Solution: Write below code in code file on page load event.

Response.Cache.SetCacheability(HttpCacheability.NoCache);

Close window without prompt

Code for aspx file

Give id to the body tag and make it runat= server.
<body id="Body" runat ="server" >

Code for aspx.cs file

Body.Attributes.Add("onload", "javascript:window.open('','_self','');window.close();");

FilteredTextBoxExtender

<ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtenderPhone" runat="server"
TargetControlID="txtPhone" ValidChars="1234567890-()" />