+ Start a Discussion
SiddharthSiddharth 

How to use Ajax 8.0 with visual studio.net 2005

Hi
I am trying to use sfdc AJAX 8.0 with .net 2005. Can anyone help me out inorder to how should i use it. I have used the
following script tag and has included the same in the aspx page as below:
 
<script src="https://na1.salesforce.com/soap/ajax/8.0/connection.js" type="text/javascript"></script>
 
Also inorder to test the ajax utlity i have added the following code in the <Head> tag.
 
<script type="text/javascript">
        function setup()
        {
            var callback = {onSuccess: display, onFailure: failed};
            var lr = sforce.connection.login(Username,password);
            var userInfo = sforce.connection.getUserInfo(callback);
        }
        function display(userInfo) {
            var doc = document.getElementById("name-span");
            doc.innerHTML = userInfo.userName;
        }
        function failed(error) {
            document.getElementById("name-span").innerHTML =
               error.toString();
        }
      </script>
 
In the body i have called the setup function as below
 
<body onload="setup()">
     Hi there! <span id="name-span"></span>
    <form id="form1" runat="server">
    <div>
       
    </div>
    </form>
</body>

This what i have found on one of the samples on community, but it doesn't seems to be working. Please help me out as how should i make use of AJAX. Also is there any way where we can call this from a simple HTML page. Do we need API support to use AJAX or is it the reference script that will make it all. Any suggestion and help would be appreciated.
DevAngelDevAngel
Using the Ajax toolkit from ASP.NET is not recommended simply because you while constantly bang your head against the same domain security issue.

You can use Ajax from ASP.NET, but you will need to write a service on your server to make your Ajax calls to.  You service would in turn, communicate with the Apex API.
SiddharthSiddharth
Can you please describe it in some more details as to what sort of service should i create in order to interact with Ajax Toolkit and how we gonna connect the ASP.Net with the service.
 
Secondly can i make use of this toolkit from a simple HTML page if yes, can you just quote some lines of code for us to figure out the way to do it. Thanks for your response
 
Sid