What is the Windows Azure platform - A quick start for beginners?


Microsoft has announced a new cloud-based version of Windows called Azure. Windows Azure allows you to build, host and scale applications in Microsoft datacenters. They require no up-front expenses, no long term commitment, and enable you to pay only for the resources you use. Azure applications run on Microsoft's data centers instead of in-house servers. There is nothing new in hosting applications on the internet, but what's interesting is what Microsoft is doing to make such applications easier to create and, crucially, to scale smoothly at times of peak demand.


Azure service will be pay-as-you-go computing, with Azure bringing new virtual servers online as needed. Azure also provides essential services such as database and document storage. The end user will not notice any difference, since Azure applications will look like any other web or Windows application, but companies benefit by off-loading investment in computer hardware and management to Microsoft, and paying only for the computing power they actually use.

This is not the first cloud computing platform. Amazon is a pioneer in the field, with services such as the Elastic Compute Cloud, which hosts virtual computers running Linux or Windows, the SimpleDB cloud database and the Simple Storage Service, which stores files online. Google has its App Engine, which is like Azure in that it hosts applications, along with a data store called BigTable. Salesforce.com has an online application platform called Force.com, which it calls Platform as a service.

Microsoft's advantage is that Azure is familiar territory for developers who already know Windows. Azure uses the .NET Framework for programming and hooks into other Microsoft services like Exchange for email and SharePoint for document collaboration. Azure also allows companies to extend their existing user directory to Azure web applications.

Microsoft expects organizations to adopt Azure gradually, integrating it with their existing systems. It is a hybrid approach that will be attractive to organizations wary of trusting everything to the cloud.

That said, Microsoft also has challenges in selling Azure. It is perceived as a Windows company, not a web company, and its current business model depends on selling software licenses for on-premise servers, supported by armies of partners with skills in installing and maintaining these systems. If Azure succeeds, the need for all these partners will diminish, so Microsoft is disrupting its own community.



Companies like Google and Amazon do not carry all this baggage. Another snag with cloud services is that they sometimes fail, with potentially severe consequences for business. "We wouldn't say we'd never have downtime," admits Mark Rogers, director of cloud services. Even in the preview phase, the industry will be watching Azure to see whether that promised resilience will be delivered.

Important Links:

What are the new features of .NET Framework 4.0?

 One more new Framework for Microsoft .NET namely .NET Framework 4.0. So, What's New in the .NET Framework 4? I think Microsoft has the answer. Here what they say, The .NET Framework is an integral Windows component that supports building and running the next generation of applications and Web services. The key components of the .NET Framework are the common language runtime (CLR) and the .NET Framework class library, which includes ADO.NET, ASP.NET, Windows Forms, and Windows Presentation Foundation (WPF).



The .NET Framework provides a managed execution environment, simplified development and deployment, and integration with a wide variety of programming languages. The .NET Framework 4 introduces an improved security model. As per my reserch I have found the following new feathers for Microsoft .NET Framework 4.0,


  1. Application Compatibility and Deployment.
  2. Core New Features and Improvements.
  3. Managed Extensibility Framework
  4. Parallel Computing.
  5. Networking.
  6. Web.
  7. Client.
  8. Data.
  9. Windows Communication Foundation.
  10.  Windows Presentation Foundation.
  11. Windows Workflow Foundation.
This is one more big top to complete.
You can find more information here

What is the difference between WCF and Web Services?

Let me tell you the definition of two and then explain the main difference.


Windows Communication Foundation(WCF):
       
         WCF stands for Windows Communication Foundation. WCF is a unified programming model for building service oriented application. WCF is the next generation of distributed applications and Web Services. It consist of a runtime and classes in System.ServiceModel namespace.

Web Services:
       
         Web Services are business logic compnents, which provide functionality via the internet using standard protocols such as HTTP. Web Services uses Simple Object Access Protocol (SOAP) in order to expose the business functionality. SOAP defines a standardized format in XML.

Differences:


WCF

Web Services
While WCF Service or a WCF component can be invoked by any protocol (like http, tcp etc.) and any transport type.

Web services can only be invoked by HTTP (traditional webservice with .asmx).

WCF are flexible.

Web Services not are flexible.
WCF service can also maintain state and session.
WCF service can not maintain state and session.

Confirmation dialog box in Code Behind using C#( C-Sharp ) in ASP.NET

You can call a confirmation dialog box from code behind using c#. Copy follow the code in respective files.

Copy this is HTML

<p>
<asp:Button id="btnSave" runat="server" Text="Save and Update 'RFFM'" OnClientClick="return UpdateRFFM();" />
</p>

Copy this in C# code behind.
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Text;
using ADI.Web;

namespace SIS
{
public partial class update_sis : System.Web.UI.Page
{
SqlCommand cmd;
SqlParameter pm;
string strForm = "";
StringBuilder sb;
string strError = "";
int UpdateStatus = -1;
string strEmailTemplate = "";

protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = "text/plain";
Response.Cache.SetCacheability(HttpCacheability.NoCache);

if (Request["form_name"] == null)
{
Response.Write("");
Response.End();
}
strForm = Utils.ToStringNullSafe(Request["form_name"]);
sb = new StringBuilder();

if (Session["ApplicationId"] == null)
{
Response.Write("Bad Request...");
Response.End();
}

int ApplicationId = int.Parse(Session["ApplicationId"].ToString());

switch (strForm)
{
case "rffm_create_user":
if (Session["email"] == null)
{
Response.Write("Bad Request");
Response.End();
}
Session["errmsg"] = "";
try
{
cmd = new SqlCommand("usp_SIS_PutUser");

// output parameter
pm = new SqlParameter("@UpdateStatus", SqlDbType.Int);
pm.Direction = ParameterDirection.Output;
cmd.Parameters.Add(pm);

// input parameters
cmd.Parameters.Add("Id", SqlDbType.Int).Value = 0;
cmd.Parameters.Add("@UserName", SqlDbType.VarChar, 50).Value = Session["Email"].ToString();

string strPassword = System.Guid.NewGuid().ToString().Substring(0, 8);

cmd.Parameters.Add("@Password", SqlDbType.VarChar, 50).Value = Utils.base64Encode(strPassword);
cmd.Parameters.Add("@Active", SqlDbType.Bit).Value = false;
int ClubId = int.Parse(Session["ClubId"].ToString());
if (ClubId > 0)
{
cmd.Parameters.Add("@Group_Id", SqlDbType.Int).Value = 31;
cmd.Parameters.Add("@Club_Id", SqlDbType.Int).Value = ClubId;
cmd.Parameters.Add("@NonClub_Id", SqlDbType.Int).Value = (object)DBNull.Value;
}
else
{
cmd.Parameters.Add("@Group_Id", SqlDbType.Int).Value = 32;
cmd.Parameters.Add("@Club_Id", SqlDbType.Int).Value = (object)DBNull.Value;
cmd.Parameters.Add("@NonClub_Id", SqlDbType.Int).Value = int.Parse(Session["Non_ClubId"].ToString());
}

Utils.executeSP(cmd);
Session.Remove("emil");
strError = "";

if (Session["errmsg"].ToString() != "") 
strError = "-1" + Session["errmsg"].ToString();

if (strError == "")
{
int UpdateStatus = int.Parse(cmd.Parameters["@UpdateStatus"].Value.ToString());
if (UpdateStatus < 0)
strError = "-1There was a problem when creating new user. Please contact Admin";
else
{
// send email
strEmailTemplate = Utils.ReadTemplate("newuser.txt");
strError = "00" + SIS_Site.SendEmail(UpdateStatus, strEmailTemplate);
}
}
} catch (Exception ex) {
strError = "-1" + ex.Message;
}
break;
case "rffm_SendVerificationEmail":
// send email
if (Session["UserId"] == null)
{
Response.Write("Bad Request");
Response.End();
}
strError = "";
strEmailTemplate = Utils.ReadTemplate("newuser.txt");
strError = "00" + SIS_Site.SendEmail(int.Parse(Session["UserId"].ToString()), strEmailTemplate);
Session.Remove("UserId");
break;
case "rffm_UserSetupVerify":
strError = "";
try
{
cmd = new SqlCommand("usp_SIS_UserSetupVerify");

// output parameter
pm = new SqlParameter("@UpdateStatus", SqlDbType.Int);
pm.Direction = ParameterDirection.Output;
cmd.Parameters.Add(pm);

SqlParameter pm2 = new SqlParameter("@EMail", SqlDbType.VarChar, 500);
pm2.Direction = ParameterDirection.Output;
cmd.Parameters.Add(pm2);

SqlParameter pm3 = new SqlParameter("@Updatetext", SqlDbType.VarChar, 200);
pm3.Direction = ParameterDirection.Output;
cmd.Parameters.Add(pm3);

SqlParameter pm4 = new SqlParameter("@UserId", SqlDbType.Int);
pm4.Direction = ParameterDirection.Output;
cmd.Parameters.Add(pm4);

// input parameters
cmd.Parameters.Add("@ApplicationId", SqlDbType.Int).Value = ApplicationId;

Utils.executeSP(cmd);

if (Session["errmsg"] != null)
strError = Session["errmsg"].ToString();

if (strError == "")
{
UpdateStatus = int.Parse(cmd.Parameters["@UpdateStatus"].Value.ToString());
if (UpdateStatus < 0)
strError = "There was an error when processing your request";
}

Session["email"] = cmd.Parameters["@EMail"].Value.ToString();
Session["UserId"] = cmd.Parameters["@UserId"].Value.ToString();
Session["Updatetext"] = cmd.Parameters["@Updatetext"].Value.ToString();

switch (UpdateStatus)
{
case 1:
strError = "1";
break;
case 2:
strError = "2";
break;
case 3:
strError = "3";
break;
case 4:
strError = Session["Updatetext"].ToString();
break;
case 5:
strError = "5" + Session["Updatetext"].ToString();
break;
default:
break;
}
}
catch (Exception ex)
{
strError = ex.Message;
}
break;

case "rffm":
Session["current_tab"] = "rffm";
try
{
cmd = new SqlCommand("usp_SIS_PutProjectProfile");

// output parameter
pm = new SqlParameter("@UpdateStatus", SqlDbType.Int);
pm.Direction = ParameterDirection.Output;
cmd.Parameters.Add(pm);

// input parameters
cmd.Parameters.Add("@ApplicationId", SqlDbType.Int).Value = ApplicationId;
cmd.Parameters.Add("@LastSavedBy", SqlDbType.VarChar, 50).Value = Session["user"].ToString();

cmd.Parameters.Add("@FeasibilityStudyDocument", SqlDbType.VarChar, 8000).Value = Request["FeasibilityStudy"];
cmd.Parameters.Add("@PlanningPermissionNotRequired", SqlDbType.VarChar, 8000).Value = Request["PlanningPermissionNotRequired"];
cmd.Parameters.Add("@Sustainable", SqlDbType.VarChar, 8000).Value = Request["Sustainable"];

string strRDMRecommendation = Request["RDMRecommendation"];
cmd.Parameters.Add("@RDMRecommendation", SqlDbType.VarChar, 8000).Value = (strRDMRecommendation == null) ? (object)DBNull.Value : strRDMRecommendation;

cmd.Parameters.Add("@Risk", SqlDbType.VarChar, 10).Value = Request["Risk"];
cmd.Parameters.Add("@Region", SqlDbType.VarChar, 50).Value = Request["Region"];
cmd.Parameters.Add("@RDMName", SqlDbType.VarChar, 50).Value = Session["user"].ToString();
cmd.Parameters.Add("@RDMReviewDate", SqlDbType.DateTime).Value = DateTime.Now;
cmd.Parameters.Add("@DesignAndPlanningPermission", SqlDbType.VarChar, 8000).Value = Request["DesignAndPlanningPermission"];
cmd.Parameters.Add("@RecommendationOfProjectNeedAgainstSDA", SqlDbType.VarChar, 8000).Value = Request["RecommendationOfProjectNeedAgainstSportsDevelopmentActivity"];
cmd.Parameters.Add("@ValueForMoneyAssessment", SqlDbType.VarChar, 8000).Value = Request["ValueForMoneyAssessment"];
cmd.Parameters.Add("@ActionId", SqlDbType.Int).Value = int.Parse(Request["ActionId"].ToString());
cmd.Parameters.Add("@ActionNotes", SqlDbType.VarChar, 500).Value = "RFFM";

Utils.executeSP(cmd);

if (Session["errmsg"] != null)
strError = Session["errmsg"].ToString();

if (strError == "")
{
UpdateStatus = int.Parse(cmd.Parameters["@UpdateStatus"].Value.ToString());
if (UpdateStatus < 0)
strError = "There was an error when processing your request";
else
Session["current_tab"] = "";
}
}
catch (Exception ex)
{
strError = ex.Message;
}
break;

case "check_session":
if (Session["ApplicationId"] != null)
{
string hfID = Request["hf_ApplicationId"].ToString();
string sfID = Session["ApplicationId"].ToString();

if (hfID != sfID)
{
strError = "-1";
}
}
break;
default:
strError = "Bad request";
break;

}

Response.Write(strError);
}
}
} 
 
 
 
Copy this in Javascript file

function UpdateRFFM()
{
var msg;
var status_code;
var rffmAction = $(".rffmAction").val();
var Risk = $(".ddlRisk").val();
var Region = $(".ddlRegion").val();
var strError = "";

if (rffmAction == "151") {
if (Risk == "")
strError = strError + "Please select a Risk\n";
if (Region == "")
strError = strError + "Please select a Region\n";                
}

if (strError != "") {
alert(strError);
return false;
}

var reply = false;

if (rffmAction == "151") {
$.post(getFullPath("update_sis.aspx"), 
{form_name: 'rffm_UserSetupVerify'}, function(data) {
if (data.length > 0)
status_code = data.substring(0, 1);
else
status_code = '';

switch(status_code) {
case '0':
UpdateRFFM_Normal();
break;
case '1':
$.post(getFullPath("update_sis.aspx"),
{form_name: 'rffm_create_user'}, function(data) {
status_code = data.substring(0, 2);
msg = data.substring(2);
if (status_code == "-1") 
alert(msg);
else {
alert('created new user account\n\n' + msg);
UpdateRFFM_Normal();
}                                    
});
break;
case '2':
UpdateRFFM_Normal();
break;
case '3':
$.post(getFullPath("update_sis.aspx"),
{form_name: 'rffm_SendVerificationEmail'}, function(data) {
status_code = data.substring(0, 2);
msg = data.substring(2);
if (status_code == "-1") 
alert(msg);
else {
alert('verification email sent\n\n' + msg);
UpdateRFFM_Normal();
}
});
break;
case '4':
alert(data);
break;
case '5':
msg = data.substring(1);
if (confirm(msg) == true) {
$.post(getFullPath("update_sis.aspx"),
{form_name: 'rffm_SendVerificationEmail'}, function(data) {
status_code = data.substring(0, 2);
msg = data.substring(2);
if (status_code == "-1") 
alert(msg);
else 
alert('verification email was sent\n\n' + msg);
UpdateRFFM_Normal();
});
}
break;                                                                                                
default:
alert(data);
break;
}
});
} else
UpdateRFFM_Normal();

return reply;
}
function UpdateRFFM_Normal() {
var reply = false;         
$.post(getFullPath("update_sis.aspx"), {form_name: 'rffm',
FeasibilityStudy: $(".FeasibilityStudy").val(),
PlanningPermissionNotRequired: $(".PlanningPermissionNotRequired").val(),
Sustainable: $(".Sustainable").val(),
RDMRecommendation: $(".RDMRecommendation").val(),
Risk: $(".ddlRisk").val(),
Region: $(".ddlRegion").val(),
DesignAndPlanningPermission: $(".DesignAndPlanningPermission").val(),
RecommendationOfProjectNeedAgainstSportsDevelopmentActivity: $(".RecommendationOfProjectNeedAgainstSportsDevelopmentActivity").val(),
ValueForMoneyAssessment: $(".ValueForMoneyAssessment").val(),
ActionNotes: $(".ActionNotes").val(),
ActionId: $(".rffmAction").val()
}, function(data) {
if (data.length > 0) {
alert(data);
return false;
} else {
window.location = getFullPath("application_form.aspx");
return false;
}
});
}

Hello, World! in C# 2010

You can learn to create classes in the C# language. Consider the following code example, which define a class:

using System;
public class Hello
{
public static void Main(string[] args)
{
System.Console.WriteLine("Hello, World!\n");
}
}

Output: Hello, World!

The preceding class declaration provides a method Main() that will display the message "Hello, World!" on your screen.

Sample resume format for Microsoft .NET with 2+ year of experience.


                                              Reference Here:           
 

Candidate Name
Ph:  +91- 9999999999

 

 
Objective: (Explain your goal here)
                      Seeking a challenging career in the field of Development of applications and producing innovative yet practical solutions to challenging problems, which would utilize my knowledge and adding continuous value to my career in multiple dimensions.                 

Professional Summary: (Explain briefly about your experience here)

§         Tell your total experience. Ex: Having 2+ years of experience in the field of Software Development using Microsoft .NET Technologies.
§         Tell about your strength Ex: Proven ability at Programming, Implementation, and Project Conceptualization of Client-Server systems.
§         Technology you know like Expert in Ex C#, ASP.NET etc..,
§         Add what you have learned in your project.
§         Tell you domain experience Ex: Functional domain experience involves Academic Solutions and E – Commerce Web Application.

Work Experience: (Mention your company name and total exp. here)

§         Working as Designation Here in Company Name, Location from Date to till Date.
§         Add working history here

Education:

§         Mention all you’re academic from 10 to Highest Degree.
§         Ex: Bachelor of Computer Science Engineering from College Name Here, Location in the year with %.


Technical Skills: 

§         Microsoft Technologies             : Ex: C#, ASP.NET, MS-SQL.
§         Web Technologies                      : Ex: HTML, JavaScript & XML.
§         Database Technologies              : Ex: Microsoft SQL-Server 2005 & MS-Access 2003.
§         Performance Tool                       : Ex: Visual Studio 2008 & 2005, SQL Server 2005.







Projects Handled

1. Name of the most recent project.
Role                                        :  You’re role in project
Client                                     Name of the client.
Environment                          :  Ex: Microsoft .NET 2.0, MS-Access 2003 & Win XP.
Tools                                       :  Ex: Visual Studio 2008 & Microsoft SQL Server 2005
Team Size                              : Size of your project team. Ex: 5
Description:

Give an abstract of your project. Give a brief explanation 1 or 2 paragraphs will do.

Responsibility:

§         Explain what you have do in the project. Don’t tell you didn’t do anything.
§         Ex: Responsible to develop Administrator Module.
§         Used 3-tier architecture (Presentation Layer, Business Logic Layer and Data Access Layers) for developing application.
§         Involve in designing windows forms.
§         Involve in creating file Setup using Visual Studio 2008.


2. Name of the most recent project.
Role                                        :  You’re role in project
Client                                     Name of the client.
Environment                          :  Ex: Microsoft .NET 2.0, MS-Access 2003 & Win XP.
Tools                                       :  Ex: Visual Studio 2008 & Microsoft SQL Server 2005
Team Size                              : Size of your project team. Ex: 5
Description:

Give an abstract of your project. Give a brief explanation 1 or 2 paragraphs will do.

Responsibility:

§         Explain what you have do in the project. Don’t tell you didn’t do anything.
§         Ex: Responsible to develop Administrator Module.
§         Used 3-tier architecture (Presentation Layer, Business Logic Layer and Data Access Layers) for developing application.
§         Involve in designing windows forms.
§         Involve in creating file Setup using Visual Studio 2008.


3. Name of the most recent project.
Role                                        :  You’re role in project
Client                                     Name of the client.
Environment                          :  Ex: Microsoft .NET 2.0, MS-Access 2003 & Win XP.
Tools                                       :  Ex: Visual Studio 2008 & Microsoft SQL Server 2005
Team Size                              : Size of your project team. Ex: 5
Description:

Give an abstract of your project. Give a brief explanation 1 or 2 paragraphs will do.

Responsibility:

§         Explain what you have do in the project. Don’t tell you didn’t do anything.
§         Ex: Responsible to develop Administrator Module.
§         Used 3-tier architecture (Presentation Layer, Business Logic Layer and Data Access Layers) for developing application.
§         Involve in designing windows forms.
§         Involve in creating file Setup using Visual Studio 2008.




Personal Details:

§         Name                                : You’re Name.
§         Email Address                  : You’re Email Address.
§         Phone                                : 91-9999999999
§         Father Name                    : You’re Father Name.
§         Date of Birth                    : you’re Date of Birth.                       
§         Martial status                  : You know this I do.             
§         Languages known            : You’re Location.
§         Passport No                      : HXXXXXXX.
§         Present address               : You’re Current Address.


You can conclude you resume her if you want or not need

How to Implementing WCF Callback in ASP.NET 3.5?

After searching here I found a method to implement WCF Callback in asp.net 3.5. I was running into similar problems where my service would make an async call to the Business layer an then wait for an event to fire back on the service. Whenver the event fired the Callback context was lost. I have not delved into the details of why this is but i ended up implementing a workaround of essentially storing a reference to the currentcontext and firing off a seperate Thread to call the to call the business layer and once it is complete fire the callback with the reference i have stored.

1) Create new class that would contain both my input request and a refence to the callback eg.
public struct MyCallbackDetails {
public MyCallbackDetails(IMyServiceCallback callback, RequestType request) : this() 
Callback = callback;
Request = request;
}

public IMyServiceCallback Callback { get; set; }

public RequestType request { get; set; }
} 
2) Then i would fire off a seperate thread passing a MyCallbackDetails object instead of just the request:
public ResponseType MyServiceMethod(RequestType request) {
//...Do Some Stuff
//Create MyCallbackDetails object to store reference to the callback and keep channel open
MyCallDetails callDetails = new MyCallDetails(OperationContext.Current.GetCallbackChannel(), request);
//Fire off a new thread to call the BL and do some work
Thread processThread = new Thread(RunCallbackMethod);
processThread.Start(callDetails);
}
3) And my RunCallbackMethod would make the BL call and respond with a callback.
void RunCallBackMethod(Object requestDetails)
{
//Use callbackdetails to make BL calls
MyCallbackDetails callDetails = (MyCallbackDetails)requestDetails;
// Make BL call - all code under here is syncrhonous
ResponseType response = BusinessLayer.BusinessMethod(callDetails.Request);
//NB: If your responsetype is a business object you will need to convert it to a service object
callDetails.Callback.SomeMethod(results);
}
Yes i have now done away with having an event from my Business Layer fire back to the Service Layer however as i am firing off a seperate thread for the Business Layer it still runs asynchronously and acts the same as if i was calling the BL directly in an ASync manner and waiting for an event to notify its completion.

What is Serialization in ASP.NET?

As a programmer you will often need to send objects to another location, you may also need to convert them to an appropriate format. So, what will you do? One of the solution is Serialization. The .NET Framework 2.0 provides built-in classes to convert data to formats that are portable, or easy to transport to another location. This process of converting data into a portable format is called Serialization.

What is Deserialization in ASP.NET?

As a programmer you may need to restore the object or data into its original form. This process of restoring the object or data to its original state is called Deserialization 

Source Code:

How to use javascript to change values of a controls inside a gridview?

There are situations where you need to change value present in grid view dynamically. In one of my project, I need to calculate price according to the number of food items selected from a drop-down list control and this will be client site operation. To do that I have used JavaScript. Below is the ASP.NET and JavaScript which you need to past it in ASP.NET page.



































 





















































 



How to create Windows Communicatin Foundation (WCF) Service Library?

To create Windows Communicatin Foundation (WCF) Service Library you need have Microsoft Visual Studio 2008 or grater version. You cannot find WCF, WPF or WWF in Microsoft Visual Studio 2005. Now that you have Microsoft Visual Studio 2008 you need to start the application by Start - Programs - Microsoft Visual Studio 2008- Microsoft Visual Studio 2008.



When you fire Microsoft Visual Studio 2008 you will get the above image. Now you need to open "New Project" dialog box. To do that click File - New - Project. Now select the WCF node after selecting the language C# or VB or C++.


 
Before clicking OK please ensure that you have selected correct .NET Framework on top, Correct Location and the Solution Name. When you hit OK you will get a default Service1.asmx file which is the WCF Service file in Solution Explorer. Service1.asmx.cs file is the code behind file which contains the actual code of you service. In this file you will write the Service logic.


 Now you are ready to create you own WCF service.

Leap Year program using C# or CSharp.

The following code checks whether the year entered by the user is a Leap Year. If the condition specified in the if statement is true, the statements in the if block are executed. And if the condition specified in the if statement is false , the statement in the else block are executed.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int Year;
Console.WriteLine("Enter the year: ");
Year = Convert.ToInt32(Console.ReadLine());
if ((Year % 4 == 0) && (Year % 100 != 0 || Year % 400 == 0))
{
Console.WriteLine("The Year you have entered is a Leap Year {0}.", Year);
}
else
{
Console.WriteLine("The Year you have entered is not a Leap Year {0}.", Year);
}
Console.ReadLine();
}
}
}

Output:

How to get Image Preview after browsing through fileupload control using JavaScript

There are situations when you work with File Upload controls and you want to show the image preview when you hit ok in the dialog box. There are many solution but we are going to demonstrate using JavaScript. Now the below code snippet uses showImage function which first splits the complete path present in file upload text box. Later it appends 'file:///' to the complete file path.

Example:



function showImage(id,img,divName,no)
{
var fileUploader = id.value;            
dots = fileUploader.split(".");

//get the part AFTER the LAST period.
fileType = "." + dots[dots.length-1];
if(fileType=='.jpg'||fileType=='.JPG'||fileType=='.gif'||fileType=='.GIF' ||fileType=='.jpeg'||fileType=='.JPEG'||fileType=='.bmp'||fileType=='.BMP'||       fileType=='.png'||fileType=='.PNG'||fileType=='.tif'||fileType=='.TIF'||fileType=='.thm'||fileType=='.THM')
{
// alert('That file is OK!');
// return true;
}
else
{
return false;
}

var filePath = fileUploader.split("\\"); 
var path = 'file:///';
for(var i = 1; i <  filePath.length;i++)
{
path += filePath[i];
if(i != filePath.length -1)
path += "/";
}  
if(path.length > 1)
{
if(no==1)
{                   
var ele= document.getElementById('<%= panellogo.ClientID %>');
ele.style.display = 'block';
var ele1= document.getElementById('<%= imglogo.ClientID %>');           
}
else if(no==2)
{
var ele= document.getElementById('<%= panelheader.ClientID %>');
ele.style.display = 'block';
var ele1= document.getElementById('<%= imgheader.ClientID %>');              
}
else if(no==3)
{
var ele= document.getElementById('<%= panelfooter.ClientID %>');
ele.style.display = 'block';
var ele1= document.getElementById('<%= imgfooter.ClientID %>');
}
else if(no==4)
{
var ele= document.getElementById('<%= panelmiddlebar.ClientID %>');
ele.style.display = 'block';
var ele1= document.getElementById('<%= imgmiddlebar.ClientID %>');           
}
ele1.src =path ; 
}
}

What are the different version of Microsoft .NET Framework?


Microsoft .NET Framework has come long way since .NET Framework 1.0 to .NET Framework 4.0. Microsoft has first launched its Framework version with .NET 1.0 followed by .NET 1.1, .NET 2.0, .NET 3.0, .NET 3.5 and last but not the least .NET 4.0. The .NET Framework 1.1 version had Common Language Runtime (CLR), Web Services and ASP.NET. Then in .NET Framework 2.0, Microsoft enhance the framework with ADO.NET, Cache Dependency, Generics, Globalization, Partial Classes, DPAPI C Data and Protection API, AJAX.

      Moving further to .NET Framework 3.0 came Windows Communication Foundation, Windows Presentation Foundation, Windows WorkFlow Foundation. In simple words .NET 3.0 = .NET 2.0 + WCF + WCS + WF + WPF. .NET Framework 3.0 was more enhanced in .NET Framework 3.5 and add some more Windows Communication Foundation, Windows Presentation Foundation, Windows WorkFlow Foundation, LINQ, AJAX, & New Windows Service Standards.

The New .NET Framework 4.0 a boom in the market. Programmer try to learn and find who easily they can develop the application. This Framework has the following features,
  1. Application Compatibility and Deployment.
  2. Core New Features and Improvements.
  3. Managed Extensibility Framework
  4. Parallel Computing.
  5. Networking.
  6. Web.
  7. Client.
  8. Data.
  9. Windows Communication Foundation.
  10.  Windows Presentation Foundation.
  11. Windows Workflow Foundation.



I have even come across the latest 2010 survey report by Scott Hanselman Blog,

How to create Session Timeout alert box and Redirect to Login.aspx page in ASP.NET

ASP.NET allows you to save values by using session state, which is an instance of the System.Web.SessionState.HttpSessionState class, for each active Web Application session. If different users are using your application, each user session will have a different session state. You can use session state to accomplish the following tasks:
  1. Uniquely identify browser or client-device requests and map them to an individual session instance on the server.
  2. Store session-sepcific data on the server for user across multiple browser or client-device requests within the same session.
  3. Raise appropriate session management events. In addition, you can write application code that make use of these event.
So, here is how you can redirect a user who's session time is out. Copy the JavaScript and HTML code in you application.





Copy this HTML code in your application.

What is .NET Framework?

If the interview ask you this question just say this,
Microsoft introduce the .NET framework with the intention of bridging the gap in interoperability between application. This framework aims at integrating various programming languages and services. It is design to make significant improvements int the code reuse, code specialization, resource management, multi-language, development. It is a platform which enables you to create robust and scalable applications. The .NET framework consists of Common Langauage Runtime(CLR), Common Language Specification(CLS), and the Just-In-Time Compiler.

.NET Architecture


Just print this image in you mind. The above image explains the .NET Architecture. It will be easy for you to explain the .NET Framework with this image.

Factorial of a number in C#(CSharp)

The following is an example of the factorial number. It is also recursive method. Have a look:

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
public int factorial(int n)
{
int result;
if (n == 1)
return 1;
else
{
result = factorial(n - 1) * n;
return result;
}
}
static void Main(string[] args)
{
Program obj = new Program();
Console.WriteLine("Factorial of 3 is " + obj.factorial(3));
Console.WriteLine("Factorial of 4 is " + obj.factorial(4));
Console.WriteLine("Factorial of 5 is " + obj.factorial(5));

Console.ReadLine();
}
}
}

Output:

Factorial

Difference between HTML and XML?

                 HTML was created by Tim Berners-Lee as a simple and effective way of generating clear and readable documents. HTML enables you to create documents and Web pages that can be read by all web browsers.

                  The World Wide Web Consortium(W3C) developed XML to enable the expansion of Web Technologies into the new domains of document processing and data interchange. It is designed to ease data exchange over the Internet. XML is a text-based markup language that enables you to store data in a structured format by using meaningful tags.

Conside a sample HTML Code:

<b> My Book </b>

<p> John Smith <br />
Tech books publications <br />
$50.00 <br />
</p>

The preceding code snippet represents information about the author, publisher, and cost of a book. However, the tags used for presenting the content do not reveal this information. The tags specify the format in which the content must be displayed on ab browser.

<book>
<name> My Book </name>
<author> John Smith </author>
<publisher> Tech books publications </publisher>
<price> $50.00 </price> 
</book>

The preceding code snippet, the content is described by using meaningul tags to represent the data. XML enables you to create a markup language for your application and does not place any restriction on the number of tags that you can define.

How to Read XML String into dataset?

I'm grabbing an XML string from a database and trying to pass it into a
dataset. Please correct me if i'm wrong

Private Function GetDataSet1() As DataSet
Dim ds As DataSet = New DataSet

Dim sb As New System.Text.StringBuilder
sb.Append("<?xml version=""1.0""?><items>")
sb.Append("<item>")
sb.Append("<itemid>100</itemid>")
sb.Append("<friendlyname1>Vegetables</friendlyname1>")
sb.Append("<friendlyname2>VG</friendlyname2>")
sb.Append(("<time>" + DateTime.Now.ToLongTimeString() + "</time>"))
sb.Append("</item>")
sb.Append("<item>")
sb.Append("<itemid>200</itemid>")
sb.Append("<friendlyname1>Fruits</friendlyname1>")
sb.Append("<friendlyname2>FR</friendlyname2>")
sb.Append(("<time>" + DateTime.Now.ToLongTimeString() + "</time>"))
sb.Append("</item>")
sb.Append("<item>")
sb.Append("<itemid>1001</itemid>")
sb.Append("<friendlyname1>Potatoes</friendlyname1>")
sb.Append("<friendlyname2>PO</friendlyname2>")
sb.Append(("<time>" + DateTime.Now.ToLongTimeString() + "</time>"))
sb.Append("<parentid>100</parentid>")
sb.Append("</item>")
sb.Append("<item>")
sb.Append("<itemid>1002</itemid>")
sb.Append("<friendlyname1>Spinach</friendlyname1>")
sb.Append("<friendlyname2>SP</friendlyname2>")
sb.Append(("<time>" + DateTime.Now.ToLongTimeString() + "</time>"))
sb.Append("<parentid>100</parentid>")
sb.Append("</item>")
sb.Append("<item>")
sb.Append("<itemid>2001</itemid>")
sb.Append("<friendlyname1>Apples</friendlyname1>")
sb.Append("<friendlyname2>AP</friendlyname2>")
sb.Append(("<time>" + DateTime.Now.ToLongTimeString() + "</time>"))
sb.Append("<parentid>200</parentid>")
sb.Append("</item>")
sb.Append("<item>")
sb.Append("<itemid>2002</itemid>")
sb.Append("<friendlyname1>Bananas</friendlyname1>")
sb.Append("<friendlyname2>BN</friendlyname2>")
sb.Append(("<time>" + DateTime.Now.ToLongTimeString() + "</time>"))
sb.Append("<parentid>200</parentid>")
sb.Append("</item>")
sb.Append("<item>")
sb.Append("<itemid>20001</itemid>")
sb.Append("<friendlyname1>Granny Smith</friendlyname1>")
sb.Append("<friendlyname2>GS</friendlyname2>")
sb.Append(("<time>" + DateTime.Now.ToLongTimeString() + "</time>"))
sb.Append("<parentid>2001</parentid>")
sb.Append("</item>")
sb.Append("<item>")
sb.Append("<itemid>20002</itemid>")
sb.Append("<friendlyname1>Macintosh</friendlyname1>")
sb.Append("<friendlyname2>MA</friendlyname2>")
sb.Append(("<time>" + DateTime.Now.ToLongTimeString() + "</time>"))
sb.Append("<parentid>2001</parentid>")
sb.Append("</item>")
sb.Append("</items>")
Dim ms As New System.IO.MemoryStream
Dim writer As New System.IO.StreamWriter(ms)
writer.Write(sb.ToString())
writer.Flush()
ms.Position = 0
ds.ReadXml(ms)
Return ds
End Function 'GetDataSet1

private static EmpDataDS GetDataSet1()
{
EmpDataDS ds = new EmpDataDS();
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<?xml version=\"1.0\"?><EmpDataDS>");
sb.Append("<Emp>");
sb.Append("<EmpID>123</EmpID>");
sb.Append("<LastName>Smith</LastName>");
sb.Append("<FirstName>John</FirstName>");
sb.Append("<SSN>222-22-2222</SSN>");
sb.Append("<DateOfBirth>" + DateTime.Now.ToLongDateString() +
"</DateOfBirth>");
sb.Append("<Litho1>litho123</Litho1>");
sb.Append("<Litho2>litho1 3</Litho2>");
sb.Append("</Emp>");
sb.Append("<Emp>");
sb.Append("<EmpID>456</EmpID>");
sb.Append("<LastName>Jones</LastName>");
sb.Append("<FirstName>Mary</FirstName>");
sb.Append("<SSN>333-33-3333</SSN>");
sb.Append("<DateOfBirth>01/01/1972</DateOfBirth>");
sb.Append("</Emp>");

for(int i = 0; i < 21 ; i++)
{

sb.Append("<Emp>");
sb.Append("<EmpID>" + (i+1000) + "</EmpID>");
sb.Append("<LastName>"+"EmpLastName"+"</LastName>");

sb.Append("<FirstName>"+"EmpFirstName:"+Convert.To String(i)+"</FirstName>");
sb.Append("<SSN>" + Convert.ToString(( Convert.ToString(i+1000) +
"000000000" )).Substring(0,9) + "</SSN>");
sb.Append("<DateOfBirth>01/01/1972</DateOfBirth>");
sb.Append("</Emp>");
}
sb.Append("</EmpDataDS>");
System.IO.MemoryStream ms = new System.IO.MemoryStream();
System.IO.StreamWriter writer = new System.IO.StreamWriter(ms);
writer.Write(sb.ToString());
writer.Flush();
ms.Position = 0;
ds.ReadXml(ms);
return ds;
}

C# Program to perform Addition, Subtraction, Multipilcation and Division operation.

The following program perform mathematical operation such as Addition, Subtraction, Multipilcation and Division operation.

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
int Number1, Number2;
char option;
int Result;

public void Number()
{
Console.WriteLine("Enter the First Number:");
Number1 = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Enter the Second Number:");
Number2 = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Main Menu");
Console.WriteLine("1. Addition");
Console.WriteLine("2. Subtraction");
Console.WriteLine("3. Multiplication");
Console.WriteLine("4. Division");

Console.WriteLine("Enter the Operation you want to perform");
option = Convert.ToChar(Console.ReadLine());

switch (option)
{
case '1':
Result = Number1 + Number2;
Console.WriteLine("The result of Addition is:{0}", Result);
break;
case '2':
Result = Number1 - Number2;
Console.WriteLine("The result of Subtraction is:{0}", Result);
break;
case '3':
Result = Number1 * Number2;
Console.WriteLine("The result of Multiplication is:{0}", Result);
break;
case '4':
Result = Number1 / Number2;
Console.WriteLine("The result of Division is:{0}", Result);
break;
default:
Console.WriteLine("Invalid Option");
break;
}
Console.ReadLine();
}

static void Main(string[] args)
{
Program objProgram = new Program();
objProgram.Number();            
}
}
} 

Output:

Creating a Sample C# program using Classes and objects.

A C# program can be written by using Visual Studio or any editor. Consider the following code, which declares the Car class and creates the object MyCar of the same class:

using System;
class Car
{
//Following are the Member variables of a class.
string Engine;
int NoOfWheels;
//Following are the Member function of a class.
public void AcceptDetails()
{
Console.WriteLine("Enter the Engin Model");
Engine = Console.ReadLine();
Console.WriteLine("Enter the number of Wheels");
NoOfWheels = Convert.ToInt32(Console.ReadLine());
}

public void DisplayDetails()
{
Console.WriteLine("The Engine Model is:{0}", Engine);
Console.WriteLine("The number of Wheels are:{0}", NoOfWheels);
}

//Class used to instantiate the Car Class.
class ExecuteClass
{
public static void Main(string[] args)
{
Car MyCar = new Car();
MyCar.AcceptDetails();
MyCar.DisplayDetails);

Console.ReadLine();
}
}

Output:
Enter the Engine Model
800CC
Enter the number of Wheels
4
The Engine Model is: 800CC
The number of Wheels are: 4

Download Free Complete Sample project on Microsoft .NET, Warehouse Management System, along with Documentation & Source Code.

You can download complete Warehouse Management System project for you reference. This project contains Documention and Source Code. Documentation has all the screen shorts of the project. This is very much helpful of new programmer in Microsoft .NET and also to Engineering Final year student in there final year project. Before downloading you can read the abstract,

Project: Warehouse Management System

Abstract:

The Warehouse Management System (WMS) mainly deals with automating the tasks of maintaining and transacting the goods. In the Warehouse Management System, inventory management is the key process. This process includes activities such as maintenance of stock details, ordering and receiving items, maintenance of receipts and items etc. It is a tedious job to maintain all these details manually. Hence, we opted to automate the Warehouse Management System.

Warehouse Management System automates the job of warehouse system.

It mainly includes five members:
Administrator
Sub-Location In-charge
Retailer
Supplier
Customer

Download Complete Project Now..!
 

About Me

It's Me!Hi, I'm Moinuddin. I'm a Software Engineer at WIPRO working on Microsoft .NET Technology. I'm interested in a wide range of technology topics, mainly Microsoft including Windows Azure, WCF, WPF, Silverlight and any other cool technology that catches the eye.

Site Info

ProjectCSharp.com is mainly about demonstrating real time examples in different technologies like ASP.NET, WCF, WPF, Silverlight, Azure etc..,

Followers

Help Links

Project CSharp (C#) Copyright © 2011. All Rights Reserved.