Sunday, May 20, 2007

My first smart phone application in visual studio 2005

What Is a Smartphone?

The worldwide mobile wireless industry is quickly moving from traditional, voice-based cellular phone services to combined voice and data services, as a result of increasing demand for mobile data access and the deployment of high-speed wireless data services utilizing a variety of wireless technologies.

Microsoft Smartphone refers to Microsoft’s platform for next-generation cell phones—basically a software architecture with Windows CE as the operating system, plus a rich set of applications such as Pocket Internet Explorer and Pocket Outlook and powerful software development tools such as .NET Compact Framework and Visual Studio 2005.




Visual Studio 2005 is the major multi-language IDE (Integrated Development Environment) for Windows applications. Both managed and unmanaged code of Windows desktop applications can be developed using Visual Studio 2005. It allows managed and unmanaged Pocket PC and Smartphone application programming targeting Windows Mobile devices. With the .NET Framework on their target systems or devices, developers can use a single set of .NET Framework classes in different languages,
with the same naming and calling convention, and similar syntax. In particular, mobile application developers can leverage their experience and programming techniques obtained from smart client application development with Visual Studio 2005, and the only difference is the class libraries: They will work with a subset of the desktop .NET Framework class libraries. Visual Studio 2005 (and the previous version,Visual Studio .NET) is the key element for rapid and high-performance .NET application development,testing, and deployment over various systems and devices.

.NET Compact Framework Type System
.NET languages such as Visual C# and Visual Basic are based on the same type system as the .NET Compact Framework and use the same class library. Thus, developers familiar with one .NET language (and therefore the .NET Compact Framework type system) can easily move to another .NET language.Every class in the .NET Compact Framework, including those with built-in value types, is directly or indirectly inherited from the System.Object class. Only single inheritance is allowed in the .NET Framework and .NET Compact Framework; a class cannot have more than one base classes. Any userdefined classes are inherited from the System.Object class if no base class is explicitly specified.

Windows Mobile 5.0 SDK for Smartphone
The Windows Mobile 5.0 SDK for Smartphone includes the Smartphone emulators (which are also in Visual Studio 2005), some command-lines tools, help files, header files, and libraries for native code development.
You can download the SDK from www.microsoft.com/downloads/
details.aspx?familyid=DC6C00CB-738A-4B97-8910-5CD29AB5F8D9&displaylang=en.

ActiveSync
You need to have Microsoft ActiveSync to connect your Smartphone device to your Windows PC.ActiveSync acts as the gateway between your PC and your Windows Mobile device so that you can easily transfer files or synchronize application data such as e-mail, a calendar, and so on. For Smartphone development, ActiveSync is needed by Visual Studio to transfer data between the development PC and the device or the emulator. You can download ActiveSync from www.microsoft.com/windows
mobile/activesync/default.mspx.

Types
There are two kinds of objects in the .NET Compact Framework: built-in value types and reference types. A value type is a primitive data type that holds only values. They are actually structures allocated on the stack. Reference types are instances of classes and must be created using the new keyword.

Generics
The .NET Compact Framework 2.0 and later support parametric polymorphism using generics.

To create an instance of a generic Stack object that holds a MyObj type in C#, you can do the following:
System.Collections.Generic.Stack myObj = new
System.Collections.Generic.Stack ();

Exception Handling
Exceptions are runtime errors that need to be handled to avoid program crashes. The .NET Framework and the .NET Compact Framework provide a built-in mechanism to handle exceptions using the wellknown



try.
{

}
catch
{
}

finally
{
}


Visual Studio 2005 will put your project into a solution, which is simply a collection of projects, one of which is designated as the “Startup” project. The Form Designer shows an image of a conceptual Smartphone with Form1
loaded into its screen. The form appears to be empty; no controls have been placed onto it. However, there is already a control named “mainMenu1” at the bottom of the form. Usually, all forms in Smartphone applications should have a Main Menu control for soft keys immediately under the screen of a Smartphone.The automatically generated project now has only two files: Form1.cs and Program.cs. Form1.cs is the
GUI interface with which a Smartphone user will interact, whereas Program.cs is the place where the.NET Compact Framework will find the main entry point and load the application.


here are my screen shots of my fist application written for smart phone





Thursday, May 17, 2007



Microsoft® Visual Studio® code name “Orcas” delivers on Microsoft’s vision of smart client applications by enabling developers to rapidly create connected applications that deliver the highest quality rich user experiences. With Visual Studio code name “Orcas”, organizations will find it easier than ever before to capture and analyze information so that they can make effective business decisions. Visual Studio code name “Orcas” enables any size organization to rapidly create more secure, manageable & reliable applications that take advantage of Windows Vista and the 2007 Office system.

more

Wednesday, May 16, 2007

Auto Numbering in Grid view

this article shows how to do auto numbering in grid view

in some cases we need to provide numbering of rows

in the folowing example i have connected a datatable with grid view

here is the htmnl code of grid view



<asp:GridView ID="GridView1" runat="server" AllowPaging="True" OnRowDataBound="GridView1_RowDataBound" AutoGenerateColumns="False" ShowFooter="True" PageSize="5" OnPageIndexChanging="GridView1_PageIndexChanging">
<Columns>
<asp:TemplateField HeaderText="No" Visible="False"></asp:TemplateField>
<asp:BoundField DataField="name" HeaderText="Name" />
<asp:BoundField DataField="gender" HeaderText="Gender" />

<asp:BoundField DataField="origin" HeaderText="Origin" />
</Columns>
</asp:GridView>




protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
DataRowView drv = (DataRowView) e.Row.DataItem;

if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[0].Text = Convert.ToString(e.Row.DataItemIndex + 1);
if (drv["gender"].ToString() == "M")
{
e.Row.Cells[3].Text = "Male";
}
else
{
e.Row.Cells[3].Text = "Female";

}

}
}


e.Row.Cells[0].Text = Convert.ToString(e.Row.DataItemIndex + 1);
is the line giving auto numbering

also the datatable has a field called gender which contains the value M/F

if it is M cell will contain Male
if it is F cell will contain Female

Thursday, May 10, 2007

Page Lifecycle of Asp.net 2.0

One of the most important things to understand when building Web applications with ASP.NET is the sequence of events during the processing of a page.

Method names and the events they bind to in ASP.NET 2.0

Method Name------------Event

Page_PreInit-----------Page.PreInit
Page_Init--------------Control.Init
Page_InitComplete------Page.InitComplete
Page_PreLoad-----------Page.PreLoad
Page_Load--------------Control.Load
Page_LoadComplete------Page.LoadComplete
Page_PreRender---------Control.PreRender
Page_DataBind----------Control.DataBinding
Page_PreRenderComplete-Page.PreRenderComplete
Page_SaveStateComplete-Page.SaveStateComplete
Page_Unload------------Control.Unload
Page_Error-------------TemplateControl.Error
Page_AbortTransaction--TemplateControl.AbortTransaction
OnTransactionAbort --TemplateControl.AbortTransaction
Page_CommitTransaction-TemplateControl.CommitTransaction
OnTransactionCommit----TemplateControl.CommitTransaction
LINQ

At the Microsoft Professional Developers Conference (PDC) 2005, Anders Hejlsberg and his team presented a new approach, Language-Integrated Query (LINQ), that unifies the way data can be retrieved in .NET. LINQ provides a uniform way to retrieve data from any object that implements the IEnumerable interface. With LINQ, arrays, collections, relational data, and XML are all potential data sources.

LINQ to Objects is an API that provides methods that represent a set of standard query operators (SQOs) to retrieve data from any object whose class implements the IEnumerable interface. These queries are performed against in-memory data.

LINQ to ADO.NET augments SQOs to work against relational data. It is composed of three parts (which appear at the bottom level of Figure 1): LINQ to SQL (formerly DLinq) is use to query relational databases such as Microsoft SQL Server.

LINQ to DataSet supports queries by using ADO.NET data sets and data tables. LINQ to Entities is a Microsoft ORM solution, allowing developers to use Entities (an ADO.NET 3.0 feature) to declaratively specify the structure of business objects and use LINQ to query them.

LINQ to XML (formerly XLinq) not only augments SQOs but also includes a host of XMLspecific features for XML document creation and queries.

Requirements

LINQ is a combination of extensions to .NET languages and class libraries that support them.

To use it, you'll need the following:

• LINQ, which is available from the LINQ Project website at
http://msdn.microsoft.com/data/ref/linq. I've used the May 2006 CTP for this book.
• NET 2.0 running on Windows 2000 (Service Pack 4), Windows Server 2003, Windows XP
Pro (Service Pack 2), or Windows Vista.
• To write C# programs using LINQ, you need either Visual Studio 2005 or Visual C#
2005

Express Edition.
• To use LINQ to ADO.NET, you need SQL Server 2005, SQL Server 2005 Express Edition,
or SQL Server 2000.
• If you want to use LINQ with .NET 3.0 (originally WinFX), you need the WinFX
Runtime

Resources

There's a lot of good material available about LINQ:
• The LINQ May 2006 CTP includes a complete set of documentation.
• The main LINQ Project site (http://msdn.microsoft.com/data/ref/linq) includes a
Forums section where thousands of developers discuss LINQ, ask for support, and
report bugs.
• At http://shop.ecompanystore.com/mseventdvd/MSD_Shop.asp you can order the DVD
that contains full sessions from PDC 2005, where LINQ was unveiled.
• On the Channel 9 site (http://channel9.msdn.com), Anders Hejlsberg and his team are
often interviewed about LINQ issues and development.
Beta 2.

Wednesday, May 09, 2007

Validating Drop Down List with RequiredFieldValidator

we can validate a drop down list with a required field validator

below is a dropdown with some sample data



<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>Select</asp:ListItem>
<asp:ListItem>Newton</asp:ListItem>
<asp:ListItem>Davinci</asp:ListItem>
</asp:DropDownList>


and for the validator i have bound it to the drop down using the control to validate property


<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="DropDownList1"
ErrorMessage="Please Select An item for the list" InitialValue="Select"></asp:RequiredFieldValidator>


after that we have to set the InitialValue property of the validator
i have set the value as select...the validator will not allow to select the default value ie "select"

also the InitialValue property is case sencitive we have to give the value correctly