Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

Asp.net website link with crm 2013 issue

$
0
0

When I retrieve or insert records into crm 2013 by asp.net page problem is it takes some time for validation. Can anyone tell me how can i reduce loading time or how can i retrieve or insert record without taking more time?

here is my code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ServiceModel.Description;
using Microsoft.Xrm.Sdk.Client;
using System.Net;
using Microsoft.Xrm.Sdk;
using System.ServiceModel;
using System.IdentityModel;
using System.Web.SessionState;


public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
           
    }


    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {

            //Authenticate using credentials of the logged in user;        

            ClientCredentials Credentials = new ClientCredentials();

            Credentials.UserName.UserName = "username";
            Credentials.UserName.Password = "mypass@word1";

           // Credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;

            //This URL needs to be updated to match the servername and Organization for the environment.

          
           Uri OrganizationUri = new Uri("http://kkmhrns:5555/RealEstate/XRMServices/2011/Organization.svc");
            Uri HomeRealmUri = null;



            //OrganizationServiceProxy serviceProxy;        

            using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, Credentials, null))
            {

                IOrganizationService service = (IOrganizationService)serviceProxy;


               
               
                    //Instantiate the contact object and populate the attributes.

                    Entity map= new Entity("new_map");

                    map["new_name"] = txtName.Text.ToString();

                    //map["new_primaryaddress"] = txtPrimaryAdd.Text.ToString();

                   // map["new_city"] = txtCity.Text.ToString();

                    //map["new_statename"] = txtState.Text.ToString();

                    Guid newContactId = service.Create(map);


                //This code will clear the textboxes after the contact is created.

                txtName.Text = "";

                txtPrimaryAdd.Text = "";

                txtCity.Text = "";

                txtState.Text = "";

                
                string message = "Data Saved Successfully.";

                System.Text.StringBuilder sb = new System.Text.StringBuilder();

                sb.Append("<script type = 'text/javascript'>");

                sb.Append("window.onload=function(){");

                sb.Append("alert('");

                sb.Append(message);

                sb.Append("')};");

                sb.Append("</script>");

                ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());
            }
        }

        catch (Exception)
        {
            txtName.Text = "";

            txtPrimaryAdd.Text = "";

            txtCity.Text = "";

            txtState.Text = "";

            string message = "Please Try Again.";

            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            sb.Append("<script type = 'text/javascript'>");

            sb.Append("window.onload=function(){");

            sb.Append("alert('");

            sb.Append(message);

            sb.Append("')};");

            sb.Append("</script>");

            ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());
        }
        Session["login"]=1;
    }
    
}


Viewing all articles
Browse latest Browse all 8223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>