Feeds:
Posts
Comments

Archive for the ‘Javascript’ Category

     Today I read another god article about JQuery selector tutorial. Here is a link for that. Two great articles about JQuery in one day, amazing !!!

Happy Programming  !!!

Chirag Darji
ASP.NET Consultant & Trainer

Read Full Post »

           Today while reading about JQuery I came across really helpful and well narrated article about JQuery Selector, JQuery Event Binding and use this key word in JQuery by Elijah Manor. You can read it here.

 

Happy programming !!!

Chirag Darji
ASP.NET Consultant

Read Full Post »

        Last week I installed Microsoft Dynamic 4.0 on my virtual machine and I found that it will be helpful for beginner like me, if there is a step by step installation guide. Lets start with OS selection.

1. You can use Windows Server 2003 or later server version. I had Windows Server 2003 R2.

2. Install latest service pack for OS you installed.

3. Install Internet Information Service.

4. Install Active Directory.

5. Configure DNS Server.

6. Create new user for domain and make him member of Administrators group.

7. Install SQL Server 2005 with Reporting Service and Analysis service.

8. Configure new account as service account for Report Server and Analysis server.

9. Install Visual Studio 2008.

10. Start installation of CRM 4.0

11. Enter display name for your Organization.

clip_image002

12. Next step is to select installation path, you can leave this as it is or select specific folder,

clip_image004

13. Next select website for CRM, I choose new website with different port address in my case it was 5555 as shown in image below,

clip_image006

14. Next you need to enter URL for Reporting server.

15. Next you have to select Organization Unit. Click on Browse button and select the root node of your domain in my case it is chirag.

clip_image008

16. On next step you need to specify security account, choose the one you created in step 6. Enter the password in password textbox and click next.

17. Select your local machine as Email Router setting or select specific machine on domain which you are using at email server. I chose my local machine so localhost.

18. Once you click next you will see System Requirements screen. If Domain user, SQL Server Reporting Service and ASP.NET are installed properly you will receive no error or warning else you will receive error message. I received following errors,

clip_image010

19. If you receive error message for SQL Server or SQL Server Reporting Service don’t be afraid. Open Services from Start – All Programs – Administrative Tools – Services. Check whether SQL Server Agent is running. If not right click on service and select property. Select Startup Type as Automatic and click on start button.

20. Another common error is for Indexing service. Follow the steps mention in point 19 to start Indexing Service.

21. You can see a warning mentioning Verify Domain User account SPN for the Microsoft Dynamics CRM ASP.NET Application Pool account. This will usually shows when you add specific domain account for security account in step 16. You can solve this warning now or after installation by following steps mentioned at http://billoncrmtech.blogspot.com/2008/08/now-i-am-master-tips-for-running-crm-40.html

22. If System Requirements screen show no error or warning on next step installation will be started.

23. Finally you will see following screen, this means your CRM is installed.

clip_image012

 

Happy Programming !!!!

Chirag Darji

ASP.NET Consultant & Trainer

Read Full Post »

        Today while working with JQuery-Ajax, I found an interesting error. I have used $.ajax() function to retrieve data from remote page. While testing I found that the page always show error : XML Parsing Error: no element found. Error does not contain specific information about the source of error. The common reason for XML Parsing Error: no element found is missing closing tag for one or two html element, so I double checked everything to make sure not miss any closing(</td> </tr>) tags.

        After searching for while I found that somehow ASP.NET treat the response of page as XML document and that’s why we receive XML Parsing Error: no element found error.

        To solve this error I added a line Response.ContentType = "text/HTML" to .cs page. This line tells ASP.NET runtime that response is HTML text and not XML.

 

Happy Programming!!!

Read Full Post »

           We all may have use JQuery in our application to build rich UI. While working with JQuery today I found that JQuery is not working on some pages where I have user mootool scripts. I search on net and found a very descriptive solution at JQuery site.

           According to this article the reason for JQuery conflict is the use of $ function. mootool and prototype.js files have their own $ function. So when we use $() and try to access JQuery (as it is shorten form of jQuery()) browser is not able to resolve which $() function it has to use. To avoid JQuery conflict we have to use jQuery.noConflict() function.

           While you read JQuery site article you may have observe the order of java script files added to web page.  Read carefully and you find that you have to add other libraries first and then add JQuery library to page. If you change the order and add the JQuery library first, either mootool(or other library which you have included) or JQuery will not work.

 

Happy Programming !!!

Read Full Post »

       We all know what JSON is and how it helps to build rich application. Recently during free time I was playing with JSON. It is easy to pass simple data types between server and client however its bit tricky to work with complex data types.

        Consider that we have Student class with FirstName, LastName and City properties. You can pass array of Student object from client to server using JSON.stringify() method. See the code,

function LoadAjax() 
{
    var t = [
             { FirstName: "Chirag", LastName: "Darji",City:"Ahmedabad" }, 
             { FirstName: "Chirag", LastName: "Darji",City:"Ahmedabad" } 
            ];
    $("#AjaxInfo")
        .load("http://chiragrdarji.blogspot.com", 
                { values: JSON.stringify(t) }
             );
            
}

Fig – (1) Passing complex data type using JSON

          Here we are passing array of two customer object from client to server using JSON. I have used JQUERY load method which use POST method to send the data to requested page. You can convert this parameter to Student class using following code,

var json = new DataContractJsonSerializer(typeof(List<Student>));
var stream = new MemoryStream(Encoding.UTF8.GetBytes(Request.Form["values"]));
List<Student> lstStudents = (List<Student>)json.ReadObject(stream);
stream.Close();

Fig – (2) Generating Lsit<Student> from JSON data type

 

Happy Programming!!!

Read Full Post »

        We have used FCK editor as an HTML editor for our recent project. It is one the best and easy to integrate HTML editor available free. When I test the editor on local server and it works fine. However when we add image using FCK editor the image path is relative to tour webpage. So if you have created an email template using FCK editor and you sends email to your customers they will not able see the image.

Set Full Image Path in FCK Editor

Fig – (1) Relative Image path in FCK editor

              We need to use full image path in FCK editor to display the image. You can change SetUrl function at following place to set full image path in FCK editor. You can find SetUrl function in fck_image.js fule at “FckEditor\editor\dialog\fck_image”. Below is the original function,

function SetUrl( url, width, height, alt )
{
    if ( sActualBrowser == 'Link' )
    {
        GetE('txtLnkUrl').value = url ;
        UpdatePreview() ;
    }
    else
    {
        GetE('txtUrl').value = url ;
        GetE('txtWidth').value = width ? width : '' ;
        GetE('txtHeight').value = height ? height : '' ;
 
        if ( alt )
            GetE('txtAlt').value = alt;
 
        UpdatePreview() ;
        UpdateOriginal( true ) ;
    }
 
    dialog.SetSelectedTab( 'Info' ) ;
}

Fig – (2) SetUrl function of FCK Editor

          Change GetE(‘txtUrl’).value = url, first line in else condition to GetE(‘txtUrl’).value = “http://www.xyz.com” + url. See the changed line below,

GetE('txtUrl').value = 'http://www.xyz.com' + url ;

Fig – (3) Changed function.

           Save fck_image.js  file and now check the image path. FCK editor will take full image path instead of relative.

Set Full Image Path in FCK Editor 2

Fig – (4) Full Image Path in FCK Editor

 

Set Full path for Flash File

            Same way you have to change fck_flash.js file at FckEditor\editor\dialog\fck_flash folder to set fill flash path in FCK Editor.

 

Happy Programming !!!

Read Full Post »

     While refreshing the AJAX skill today I wrote a simple code to display please wait message while asynchronous postback. I added one Update Panel, one Update Progress panel and a button control and registered button  as Asynchronous Postback Trigger control. I assign my UpdatePanel’s id as AssociatedUpdatePanelID to UpdateProgress panel. I ran the code found that Progress panel is not displayed while async postback, strange !!!! Then I remember few basic points regarding Update Panel and Update Progress which is available on MSDN and found that If we set AssociatedUpdatePanelID to Update Progress panel then we must have to button as inside Update Panel if register button as Async Postback trigger then it will not work. Below is the points (that MSDN Suggests) needs to remember while using UpdateProgress,

The AssociatedUpdatePanelID property has the following effect on UpdateProgress control behavior,

When the AssociatedUpdatePanelID property is not set, the UpdateProgress control is displayed for the following postbacks:

  • Postbacks that originate from inside any UpdatePanel control.
  • Postbacks that originate from controls that are asynchronous triggers for any UpdatePanel control.

When the AssociatedUpdatePanelID property is set to an UpdatePanel control ID, the UpdateProgress control is displayed for postbacks that originate from inside the associated UpdatePanel control.

If the AssociatedUpdatePanelID property is set to a control that does not exist, the UpdateProgress control will never be shown.

You must provide client script to display an UpdateProgress control when a target UpdatePanel control is updated in the following circumstances

  • When a postback from a control is registered as an asynchronous postback trigger for the panel, and there is an UpdateProgress control on the page. However, the AssociatedUpdatePanelID property is not set to the panel’s ID.
  • When postbacks from controls are registered as asynchronous postback controls by using the RegisterAsyncPostBackControl method of the ScriptManager control.

 

Happy Programming!!!!

Read Full Post »

      Sometime we need to find when the page is loaded or page is completely loaded before specific java script function is called.  As we all know if try to access DOM element using document.getElementBtId() before page is loaded or page is completely loaded we get error. So to prevent the error we can user following java script to detect page is loaded?

   1: var body = document.getElementsByTagName('BODY')[0];

   2:  

   3: if (body && body.readyState == 'loaded') {

   4:     AfterLoad();

   5: } else {        

   6:     if (window.addEventListener) {

   7:         window.addEventListener('load', AfterLoad, false);

   8:     } else {

   9:     window.attachEvent('onload', AfterLoad);

  10:     }

  11: }

  12: function AfterLoad() {

  13:     alert("page loaded !!!");

  14: }

Fig (1) – Detect Page is loaded !!

 

Happy Programming !!!

Read Full Post »

You may receive “Page Methods is undefined while calling Server Side function from Client Side Code using PageMethods in AJAX. The possible cause can be,

1. You may have not added EnablePageMethods=”true” in ScriptManager tag.

   1: <ajax:ScriptManager
   2:     EnablePageMethods="true" ID="ScriptManager1" runat="server">
   3: </ajax:ScriptManager>

2. You have a pre-release version of Atlas or the Ajax beta installed. Download latest version from here.

3. Your application’s virtual directory is configured for .NET Framework 1.1

4. Your application does not have the Ajax DLL in its Bin folder. The DLL is “System.Web.Extensions.dll”. You may find the DLL at “C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025”. You may have this DLL at different location.

5. Your Web.config does not include a WebServices section. To verify this create a new website and select Ajax Enable Website. You can see that all necessary tags are included in web.config file of this website. You cab replace new web.config file with your application.

Happy Programming !!!

Read Full Post »

Older Posts »