google

Newest Post

Free Microsoft .net Technology Online Training: How it works for Trainers?

| Thursday, March 21, 2013
Read more »

Free Microsoft .net Technology Online Training: How it works for Trainers?

Posted by : Stranger
Date :Thursday, March 21, 2013
With 0comments

Web response to display data from another website

| Wednesday, March 20, 2013
Read more »
Data from another website can be displayed in our own website using simple "WebRequest" and "WebResponse".WebRequest uses URL of the another website which can be passed hard coded or dynamically.

Add a Label control on the webpage.

 <asp:Content ID="Content2" ContentPlaceHolderID="generalContent" runat="Server">  
   <asp:Label ID="lblDisplay" runat="server">   
   </asp:Label>  
 </asp:Content>  

Add following code in Page_Load or any other event like button click etc.

 WebRequest wReq = WebRequest.Create("https://www.youtube.com/watch?v=CGu8W4cFlUw");  
       WebResponse mRes = wReq.GetResponse();  
       StreamReader sr = new StreamReader(mRes.GetResponseStream());  
       string sHTML = sr.ReadToEnd();  
       sr.Close();  
       mRes.Close();  
       if (sHTML != string.Empty && sHTML != null)  
       {  
         lblDisplay.Text = sHTML;  
       }  

Add required namespaces in the cs file

 using System;  
 using System.Collections.Generic;  
 using System.IO;  
 using System.Linq;  
 using System.Net;  
 using System.Web;  
 using System.Web.UI;  
 using System.Web.UI.WebControls;  

and That's it.

Enjoy!!!

The output in the browser will be


Web response to display data from another website

Posted by : Stranger
Date :Wednesday, March 20, 2013
With 1 comments:
Tag : ,

LINQ Tutorial-Adding, Updating and Deleting Data

| Monday, March 11, 2013
Read more »

LINQ Tutorial-Adding, Updating and Deleting Data

Posted by : Stranger
Date :Monday, March 11, 2013
With 3comments
Tag :

Integrate Linked In JavaScript API with ASP.NET

|
Read more »
This page on Linked - In developer website explains the method to integrate JavaScript API with ASP.NET.
There are various ways Linked-In can be integrated in an ASP.NET website. I will explain the JavaScript API integration in this article.

Following are the steps of the Linked-In JS API integration.

1. Register yourself as developer on the linked-in website.
2. Create a new application or use an existing one. API Key and Secret Key of the application will be used for this integration.
3. Most Important - Make sure to specify the domain or list of domains for which above API key will be used, in "JavaScript API Domains" as in this screenshot:

JavaScript API Domains
4.Add following script in the <head> section of the html or aspx page to access the Linked-In API framework.
 <script type="text/javascript" src="http://platform.linkedin.com/in.js">  
  api_key: your_api_key_goes_here  
 </script>  

5. Add the following HTML to the body of your document to display the Linked-In Sign In button.
 <script type="in/Login">  
 </script>  



6. On clicking the above button, it should popup an authorization window asking you to Sign In to LinkedIn and grant API permission to your application. By default this pop up will ask for "Basic Profile Permissions" only.
Sign In and grant API permission
7. Test the page by reloading the page a few times. Notice that the login button reappears every time, even though you have already logged into the app and granted permission.Configure the authorize parameter in the framework script tag:
 <script type="text/javascript" src="http://platform.linkedin.com/in.js">  
  api_key: your_api_key_goes_here   
  authorize: true  
 </script>  

So far we have done integrating the LinkedIn Sign In and API permissions. In the next part I will explain how to display the details from the LinkedIn Profile.

LinkedIn JavaScript API uses REST services as back end. Lets rewrite the code above.

1. Introduce two parameters while importing the JS API framework.
 <script type="text/javascript" src="http://platform.linkedin.com/in.js">  
     api_key: your api key  
     onLoad: onLinkedInLoad  
     authorize: true  
   </script>  

The onLoad parameter tells the framework to wait until it's finished loading and then invoke a JavaScript function of your choosing. In this example, the function's name is onLinkedInLoad.
As discussed previously, setting authorize to true automatically authenticates any viewers who have previously granted your site permission using the JavaScript API.

2.The IN Object- The IN object is your way to hook into the LinkedIn JavaScript API. It's what the framework script tag inserts into the page. All the JavaScript API functions will begin with IN..
 function onLinkedInLoad() {  
       IN.Event.on(IN, "auth", onLinkedInAuth);  
     }  

In.Events. Events listen for activities, and run code when they happen. This line says to listen for the auth event, which triggers when someone signs in, and execute the onLinkedInAuth() function afterwards. Events are covered in more detail in the JavaScript API Reference.

3. Add the following HTML to the body of your document to display the Linked-In Sign In button.
 <script type="in/Login">  
 </script>  




4. Fetching profile information
 function onLinkedInAuth() {  
       IN.API.Profile("me")  
       .result(displayProfiles);  
     }  

The first part, IN.API.Profile("me"), makes a request to the LinkedIn API servers for the profile belonging to the signed-in user. The keyword "me" is a special short-hand way of referring to the signed-in member.
After it successfully retrieves data, the JavaScript framework sends the information to a callback function you specify in the result() method. In this case, it's a reference to the displayProfiles() function which we'll define below.
The In.API.Profile() method supports three of ways to identify a member: "me", member ids (like 4KoRHzE6GO), and public profile URLs.

5. Add controls in the body of the page to display profile details.
 Hello  
   <asp:Label ID='lblName' runat="server"></asp:Label>  

6. Results from the Profile API come grouped under one parameter.The displayProfiles() function receives a parameter which is the complete JSON-formatted result of the underlying call. By default the data is always in a values array. Since this is the Profile API call, values contains profile data. In this case, there's only one profile for the signed-in member, me, so it's in values[0]. The fields and field names returned for a profile are : id, firstName, lastName, headline, and pictureUrl.

 function displayProfiles(profiles) {  
     member = profiles.values[0];  
      document.getElementById("lblName").innerHTML = member.firstName + " " + member.lastName;  
 }  

7. To fetch additional profile details, fields() method can be used. Change the "onLinkedInAuth" method to include fields() method.

 function onLinkedInAuth() {  
       IN.API.Profile("me")  
       .fields("firstName", "lastName", "industry", "location:(name)", "picture-url", "headline", "summary")  
       .result(displayProfiles);  
     }  

8. Change the "displayProfiles" method as follows and add additional control in the body of the page to display more details.

 function displayProfiles(profiles) {  
       member = profiles.values[0];  
       alert(JSON.stringify(member));  
       member.lastName + "<br/> Location is " + member.location.name + " </p>";  
       document.getElementById("lblName").innerHTML = member.firstName + " " + member.lastName;  
       document.getElementById("imgProfile").src = member.pictureUrl;  
       document.getElementById("lblSummary").innerHTML = "<pre>" + member.summary + "</pre>";  
       document.getElementById("lblIndustry").innerHTML = member.industry;  
 }  

Please note
 alert(JSON.stringify(member)); 

This will display the JSON string returned by the LinkedIn API call.

LinkedIn contains many other useful resources beyond member profiles. The JavaScript API allows you access to every part of LinkedIn exposed through REST APIs. For a complete list read out REST APIs documentation.
The commonly used resources have high-level wrapper classes to help you access them (IN.API.Profile is one such wrapper). Currently, these are:
  • IN.API.Connections
  • IN.API.MemberUpdates
  • IN.API.NetworkUpdates
  • IN.API.PeopleSearch
  • IN.API.Profile
9. Handling errors:  The JavaScript API will inspect the REST response on your behalf and if an error occurred (the API returns an HTTP non-200 status code), the framework will notify you. You can specify a special error handler for using the optional error() method:

 function onLinkedInAuth() {  
       IN.API.Profile("me")  
       .fields("firstName", "lastName", "industry", "location:(name)", "picture-url", "headline")  
       .result(displayProfiles)  
       .error(displayProfilesErrors);  
     }  

Add a div in the body to display the errors.

 <div id="profiles">  
   </div>  

Display error message in the above div as follows:

 function displayProfilesErrors(error) {  
       profilesDiv = document.getElementById("profiles");  
       profilesDiv.innerHTML = error.message;  
       console.log(error);  
     }  

LinkedIn Members publish a variety of information about themselves on their member profile. Check out the link to view list of Profile Fields.

By default the API call processes "BasicPofile" permissions vide r_basicprofile.

To access email address fields, API requires r_emailaddress member permission.
To access profile related fields which are not covered under basic profile permissions like three-current-positions, date-of-birth etc, the API request requires r_fullprofile member permission.
To access contact information fields, API requires r_contactinfo member permission.
To access connection fields, API requires r_networkmember permission.
To access group membership fields, API requires rw_groupsmember permission.
To access network update fields, API requires rw_nusmember permission.

Scope parameter is added in the framework request to access fields other than basic profile.

 <script type="text/javascript" src="http://platform.linkedin.com/in.js">  
     api_key: your api key  
     scope: r_basicprofile r_emailaddress r_fullprofile  
     onLoad: onLinkedInLoad  
     authorize: true  
   </script>  

All basic, email and full profile fields can be accessed with above permissions.

 function onLinkedInAuth() {  
       IN.API.Profile("me")  
       .fields("firstName", "lastName", "industry", "location:(name)", "picture-url", "headline", "summary", "num-connections", "public-profile-url", "distance", "positions", "email-address", "educations", "date-of-birth")  
       .result(displayProfiles)  
       .error(displayProfilesErrors);  
     }  


Leave comments if anything in above code doesn't work. I have working code with me. Drop me your email id to get same.


Reference Links

Integrate Linked In JavaScript API with ASP.NET

Posted by : Stranger
Date :
With 9comments

Facebook Messenger App is Updated With Improvements to Group Conversations.

| Thursday, March 7, 2013
Read more »
Facebook Messenger for iPhone has been updated with improvements to group conversations.

Text your friends for free. Get Facebook Messenger to instantly reach friends on their smart phones, feature phones or desktop computers.

Features:
- Chat with a group
- Send voice messages, photos, smileys and other emoji
- Get push notifications
- Know who’s seen your messages
- Include your location

What's New In This Version:
Updates to group conversations
- Name a group right from the top of your conversation
- Get to your group conversations in one tap – just swipe left to see them in your sidebar
- Search for group conversations by name or look them up by friends in the group
- Other improvements and bug fixes

You can download Facebook Messenger from the App Store for free.

Facebook Messenger App is Updated With Improvements to Group Conversations.

Posted by : Stranger
Date :Thursday, March 7, 2013
With 0comments
Tag :

Architecture of .Net Framework

| Saturday, March 2, 2013
Read more »
The .Net Framework is an inbuilt windows component that supports Building and running the next generation of application xml web services. The .Net Framework has been developed to cater to the following objectives and Requirements:
  • To provide a consistent object-oriented environment to develop applications;
  • To provide a code execution environment that simplifies deployment and versioning;
  • To provide a code execution that eliminates the issues faced by scripted environments with respect to performance.
  • To provide a common programming model where the choice of a programming
  • Language becomes a matter of choice.
The .Net framework is made up of two components- Common Language Runtime (CLR) and the .Net Framework Class Library (FCL).The CLR is the basic for the .Net Framework and provides various services that application can use. It also forms the environment that other application run on.

The runtime is supposed to be an agent that manages code at execution time, providing core services, such as memory management, thread management, and remoteing. It also encourages security and robustness by implementing safety and other type of code accuracy. Since code management is a basic principal of the runtime is known as unmanaged code. The .Net framework consists of web Forms, Windows Forms and console applications the pertain to the presentation layer of an application.
  • Web forms are used in web-based application whereas windows forms are used in windows based application.
  • You can create a character-based console application that can be executed from the command line.
  • .Net Framework consists of two other component the .Net Framework Base classes the CLR.

Common Language Runtime
  • The Common Language Runtime (CLR) is a core component of Microsoft's .NET initiative. It is Microsoft's implementation of the Common Language Infrastructure (CLI) standard, which defines an execution environment for program code. In the CLR, code is expressed in a form of bytecode called the Common Intermediate Language (CIL, previously known as MSIL—Microsoft Intermediate Language).
  • Developers using the CLR write code in a language such as C# or VB.NET. At compile time, a .NET compiler converts such code into CIL code. At runtime, the CLR's just-in-time compiler converts the CIL code into code native to the operating system. Alternatively, the CIL code can be compiled to native code in a separate step prior to runtime by using the Native Image Generator (NGEN). This speeds up all later runs of the software as the CIL-to-native compilation is no longer necessary.
  • Although some other implementations of the Common Language Infrastructure run on non-Windows operating systems, Microsoft's implementation runs only on Microsoft Windows operating systems.
Intermediate Language

In the .NET environment, a source code which is written in any one of the programming languages should be translated into a byte code format before its execution. This byte code format is called Common Intermediate Language(CIL) or Microsoft Intermediate Language (MSIL).
Common Intermediate Language:
  • Common Intermediate Language (CIL, pronounced either "sil" or "kil") (formerly called Microsoft Intermediate Language or MSIL) is the lowest-level human-readable programming language defined by the Common Language Infrastructure specification and used by the .NET Framework and Mono. Languages which target a CLI-compatible runtime environment compile to CIL, which is assembled into bytecode. CIL is an object-oriented assembly language, and is entirely stack-based. It is executed by a virtual machine.
  • CIL was originally known as Microsoft Intermediate Language (MSIL) during the beta releases of the .NET languages. Due to standardization of C# and the Common Language Infrastructure, the bytecode is now officially known as CIL. Because of this legacy, CIL is still frequently referred to as MSIL, especially by long-standing users of the .NET languages.
JIT Compilation
  • The high level programming languages that need to be compiled require a runtime, so that the architecture on which the language runs is provided with details on how to execute its code.
  • All the programming languages use its corresponding runtime to run the application.
  • For example, To run an application developed using Visual Basic, the computer on which the application will be run must be installed with the Visual Basic runtime. The Visual Basic runtime can run only the applications developed with Visual Basic and not the ones developed with any other programming language like Java.
  • In the .NET Framework, all the Microsoft .NET languages use a common language runtime, which solves the problem of installing separate runtime for each of the programming languages. Microsoft .NET Common Language Runtime installed on a computer can run any language that is Microsoft .NET compatible.
  • The main advantage of the .NET Framework is the interoperability between different languages. As all the Microsoft .NET languages share the same common runtime language, they all work well together. For example, you can use an object written in C# from Visual Basic.NET. The same applies for all the other Microsoft .NET languages.
  • When you compile a Microsoft.NET language, the complier generates code written in the Microsoft Intermediate Language (MSIL). MSIL is a set of instructions that can quickly be translated into native code.
  • A Microsoft.NET application can be run only after the MSIL code is translated into native machine code. In .NET Framework, the intermediate language is complied "just in time" (JIT) into native code when the application or component is run instead of compiling the application at development time. The Microsoft.NET runtime consists of two JIT compilers. They are standard JIT compiler and the EconoJIT compiler. The EconoJIT compiler compiles faster than the standard JIT compiler, but the code it produces is not as optimized as the code obtained from the standard JIT compiler.
Managed Code
The code whose execution is managed by the .Net Framework Common Language Runtime is known as Managed code. It refers to a contract of cooperation between natively executing code and the runtime.The process of compiling and executing managed code in given below.
  • Compile a programs developed in a language that targets the CLR, instead of compiling the source code into machine level code, the compiler translates it into Microsoft Intermediate language(MSIL) or Intermediate language (IL).No matter which lang has been used to develop the application , it always get translated into IL. This ensure languages interoperability.
  • In addition to translating the code into IL, the compiler also produce metadata about the program during the process of compilation. Meta data contains the description of the program
  • The IL and the metadata are linked in an assembly.
  • The compiler creates the .EXE or .DLL file.
  • Execute the .Exe or .DLL file, the code and all the other relevant information from the base class library is sent to the class loader. The class loader the code in the memory.
  • Before the code can be executed, the .Net framework needs to convert the IL into native or CPU-specific code. The Just-In-Time (JIT) compiler translator the code from IL into managed native code.
  • The CLR supplies a JIT compiler for each supported CPU architecture.
  • During JIT compilation, the code is also checked for type safety. Type safety ensures that objects are always accessed in a compatible way, you try to pass an 8-byte value to a method the accepts a 4-byte value as it parameter.
  • After translating the IL into native code, the converted code is sent to the .Net runtime manager.
  • The .Net runtime manager executes the code. While executing the code, security check the performed to ensure that the code has the appropriate permissions for accessing the available resources.

Metadata
  • Metadata is binary information describing your program that is stored either in a common language runtime portable executable (PE) file or in memory. When you compile your code into a PE file, metadata is inserted into one portion of the file, while your code is converted to Microsoft intermediate language (MSIL) and inserted into another portion of the file.
  • Every type and member defined and referenced in a module or assembly is described within metadata. When code is executed, the runtime loads metadata into memory and references it to discover information about your code's classes, members, inheritance, and so on.
Benefits of metadata:

     Metadata is the key to a simpler programming model, eliminating the need for Interface Definition Language (IDL) files, header files, or any external method of component reference. Metadata allows .NET languages to describe themselves automatically in a language-neutral manner, unseen by both the developer and the user. Additionally, metadata is extensible through the use of attributes. Metadata provides the following major benefits:



Self-describing files:

  • Common language runtime modules and assemblies are self-describing. A module's metadata contains everything needed to interact with another module.
  • Metadata automatically provides the functionality of IDL in COM, allowing you to use one file for both definition and implementation. Runtime modules and assemblies do not even require registration with the operating system.
  • As a result, the descriptions used by the runtime always reflect the actual code in your compiled file, which increases application reliability.
Language Interoperability and easier component-based design:

  • Metadata provides all the information required about compiled code for you to inherit a class from a PE file written in a different language.
  • You can create an instance of any class written in any managed language (any language that targets the common language runtime) without worrying about explicit marshaling or using custom interoperability code.
Attributes:

  • The .NET Framework allows you to declare specific kinds of metadata, called attributes, in your compiled file. Attributes can be found throughout the .NET Framework and are used to control in more detail how your program behaves at run time.
  • Additionally, you can emit your own custom metadata into .NET Framework files through user-defined custom attributes. For more information, see Extending Metadata Using Attributes.
Metadata Tools:
Several tools are used to handle metadata.
  • Reflection is a tool which is used to handle metadata.
  • Third party tools (Ex : Post sharp, Mono ceil) are used to retrieve and manipulate metadata.
  • Manifest is a text file that contains metadata about .NET assemblies.
Automatic Memory Management

Automatic memory management is one of the services that the common language runtime provides during Managed Execution. The common language runtime's garbage collector manages the allocation and release of memory for an application. For developers, this means that you do not have to write code to perform memory management tasks when you develop managed applications. Automatic memory management can eliminate common problems, such as forgetting to free an object and causing a memory leak, or attempting to access memory for an object that has already been freed. This section describes how the garbage collector allocates and releases memory.
  1. Allocating Memory
  2. Releasing Memory
  3. Generation and Performance
  4. Releasing memory for Unmanaged Resource

Architecture of .Net Framework

Posted by : Stranger
Date :Saturday, March 2, 2013
With 1 comments:
Tag : ,

Calculate Age from Date of Birth Using Java Script.

|
Read more »
Calculate Age from Date of Birth Using Java Script.: In my previous posts, I explained jQuey .toggleClass() Example in ASp.Net , jQuery Draggable Div Example in ASP.Net , Disable cut, copy and...

Calculate Age from Date of Birth Using Java Script.

Posted by : Stranger
Date :
With 0comments

Currency conversion using web service in Asp.Net

| Friday, March 1, 2013
Read more »
This article explains the conversion of currency with real time currency conversion rates. This is done using a web service which contains real time rates of conversion.

The web service being used is

 http://www.webservicex.net/CurrencyConvertor.asmx

Add following controls on the page
1. Dropdownlist for "From Currency"
2. Dropdownlist for "To Currency"
3. Textbox for "Value to be converted"
4. Textbox for "Result"



.Aspx page will have following code for the above controls:

 From Currency:&nbsp;  
     <asp:DropDownList ID="ddlFrom" runat="server" Width='205' DataSourceID='sqlDsCountries'  
       DataTextField='CountryName' DataValueField='CountryCode'>  
     </asp:DropDownList>  
     <br />  
     <br />  
     To Currency:&nbsp;  
     <asp:DropDownList ID="ddlTo" runat="server" Width='205' DataSourceID='sqlDsCountries'  
       DataTextField='CountryName' DataValueField='CountryCode'>  
     </asp:DropDownList>  
     <br />  
     <br />  
     Value to be converted:&nbsp;  
     <asp:TextBox ID="txtValue" runat="server" Width='200'></asp:TextBox><br />  
     <br />  
     Result:&nbsp;<asp:TextBox ID="txtResult" runat="server" Width='200'></asp:TextBox>  

Add a button in the aspx page to retrieve the results and write following code in the button click

       string Result = "";  
       string url="";   
       double value= Convert.ToDouble(txtValue.Text);   
       url = "http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=" + ddlFrom.SelectedValue + "&ToCurrency=" + ddlTo.SelectedValue + "";   
       HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);   
       HttpWebResponse response = (HttpWebResponse)request.GetResponse();   
       StreamReader Stream = new StreamReader(response.GetResponseStream());   
       XmlDocument doc = new XmlDocument();   
       Result = Stream.ReadToEnd();   
       doc.LoadXml(Result);   
       string CR = doc.GetElementsByTagName("double").Item(0).InnerText;   
       double rate= double.Parse(CR);   
       double result= value * rate;   
       txtResult.Text = Convert.ToString(result);  


Please share your comments and any queries.

Currency conversion using web service in Asp.Net

Posted by : Stranger
Date :Friday, March 1, 2013
With 2comments
Next Prev
▲Top▲