Thursday, November 10, 2011

Barcamp Kerala 11

Barcamp Kerala 11

Venue : IIM Calicut
Date : 20th November 2011

Sessions
Microsoft Silverlight                                            -  Shalvin P D
IITs & IIMs - Are they (still) Socially Relevant ?  - Praseed Pai
Making your First Dollar with your PC                 - Arun Basil Lal
Html 5 and Beyond                                             -  Shwetank Dixit
Social media and Business                                   - Hari K T
The Conversation Club                                        - Sebastian Panakal

Session details

 

Wednesday, August 17, 2011

Kerala Microsoft User Group - August 1011 Meeting

20th Aug 2011 - Kochi



Venue: Orion India Systems Pvt Ltd, 103, 2nd floor, Tejomaya, Info park SEZ, Kakkanad, Kochin-682030


Agenda

09:30 - 09:40 Community updates

09:40 - 11:00 "Design Patterns in .Net" by Yanesh Tyagi

11:00 - 11:45 JavaScript MVVM in ASP.NET with KnockoutJS by Shiju Varghese

11:45 - 12:00 Tea Break (15 min)

12:00 - 12:45 Instrumenting & Profiling in .NET Apps" by Abraham Peter

12.45 - 01:00 Ask the experts





Mono

Mono is open source cross platform implementation of .Net I am using Mono in Ubuntu 10.10.
The preferred way to develop Mono in Linux is using MonoDevelop. MonoDevelop is a Mono IDE.

First let's see how to develop Console Application in Mono.
Once you have installed Mono you can go to the Terminal by going to Application, Accessories and select Teminal. The mono C# compiler is mcs.

class Hello
{
  public static void Main()
  {
    System.Console.WriteLine("Shalvin");
  }
}



So type mcs .cs in the terminal for compiling the C# file.
Once it is compiler you can access the exe using
mono .exe.


















Windows Forms
using System;
using System.Windows.Forms; 

class frmHello : Form
{
  public static void Main()
  {
    Application.Run(new frmHello());
  }
}

Monday, July 18, 2011

Ado .Net DataSet and WPF

If an element uses a binding expression and its DataContext property is null the element continues its search up the element tree. This search continues until the element finds a data object or reaches the toplevel container, which is the user control that represents the page.


using System.Data;
using System.Data.SqlClient;


SqlConnection cnn;
SqlDataAdapter da;
DataSet ds = new DataSet();
private void Window_Loaded(object sender, RoutedEventArgs e)
{
    cnn = new SqlConnection(@"Data Source=.\sqlexpress;Integrated Security=sspi;Initial catalog=AirLines");
    cnn.Open();
    da = new SqlDataAdapter("select * from Location", cnn);
    da.Fill(ds, "Loc");
    LayoutRoot.DataContext = ds.Tables["Loc"];
}


<Grid Name="LayoutRoot">
<ListBox ItemsSource="{Binding}"
            DisplayMemberPath="LocationName"
            Height="100" HorizontalAlignment="Left" Margin="10,10,0,0" Name="listBox1" VerticalAlignment="Top" Width="120" />
</Grid>


Binding to DataGrid

<Grid   Name="LayoutRoot">
    <DataGrid ItemsSource="{Binding}" AutoGenerateColumns="True" Height="150" HorizontalAlignment="Left" Margin="17,13,0,0" Name="dataGrid1" VerticalAlignment="Top" Width="325" />
</Grid>


WPF DataGrid Custom Columns
<Grid   Name="LayoutRoot">
<DataGrid ItemsSource="{Binding}" AutoGenerateColumns="False"  HorizontalAlignment="Left" Margin="42,12,0,0" Name="dataGrid1" Width="296">
    <DataGrid.Columns>
        <DataGridTextColumn Header="Serial No" Binding="{Binding LocationId}" />
        <DataGridTextColumn Header="Location Name" Binding="{Binding LocationName}" />
        <DataGridTextColumn Header="Latitude" Binding="{Binding Latitude}" />
        <DataGridTextColumn Header="Longitude" Binding="{Binding Longitude}" />
    </DataGrid.Columns>
</DataGrid>
</Grid>

{Binding LocationName} is the shorthand to {Binding Path=LocationName}


Thursday, July 7, 2011

User Group Meeting - 9th July 2011 - Kochi

Venu: Orion India Systems Pvt Ltd, 103, 2nd floor, Tejomaya, Info park SEZ, Kakkanad, Kochin-682030




09:30 - 09:40 Community updates
09:40 - 10:40 C# Test Automation by Praseed

10:40 - 11:20 Silverlight - Prism by Mahima
11:20 - 11:40 Tea Break (15 min)
11:40 - 12:30 Sharepoint 2010 programing by Abraham
12.30 - 01:00 Ask the experts


Register

Wednesday, June 8, 2011

User Group Meeting - 11th June 2011 - Kochi

Venu: Orion India Systems Pvt Ltd, 103, 2nd floor, Tejomaya, Info park SEZ, Kakkanad, Kochin-682030

Agenda

09:30 - 09:40 Community updates
09:40 - 10:30 Scaffolding with EF 4.1 and ASP.NET MVC 3
10:30 - 11:15 Debugging Techniques in Visual Studio
11:15 - 11:30 Tea Break (15 min)
11:30 - 12:30 Introducing Parallel programming in .net 4.0
12.30 - 01:00 Ask the experts

Register

Details

It is a free event. Please convey the message to your friend and ensure their participation.

Tuesday, May 10, 2011

Converting Silverlight Application to use WCF RIA Services

Enabling WCF RIA services to an existing Silverlight application is easy and straight forward. Navigate to the properties of Silverlight Project and go WCF RIA Services Link and select the ProjectName.Web.

Monday, May 9, 2011

Editor - Ajax Control Toolkit


Editor control is an Html Editor in Ajax Control Toolkit control. Html Editors found extensive use in Content Mangament Systems and Blog Engines.

StreamWriter sw;
protected void Button3_Click(object sender, EventArgs e)
{
Response.Write(Editor1.Content);
sw = File.CreateText(Server.MapPath("Shalvin.txt"));
sw.WriteLine(Editor1.Content);
sw.Close();

}

Thursday, May 5, 2011

TechEd on the road - 14th May at ParkCenter, Technopark,Trivandrum

A free full day event by Kerala Microsoft User Group.

Agenda
08:45 - 09:30 Registration Confirmation
09:30 - 09:45 Opening / Welcome Note
09:45 - 10:45 Building cross browser web applications with HTML5/CSS3 by Rajasekharan Vengalil
10:45 - 11:30 Creating & Deploying Application for Azure by Amal
11:30 - 11:45 Tea Break
11:45 - 12:30 Visual Studio Productivity tools by Shoban
12:30 - 01:15 Windows Phone App development with XNA by Sreejumon
01:15 - 02:15 Lunch Break
02:15 - 03:00 Introducing Parallel Programming with .Net 4.0 by Bijith
03:00 - 03:45 Windows Work Flow 4.0 – A sneak Peek by Jeen
03:45 - 04:00 Tea break
04:00 - 05:00 Strategies for client side storage in the web world – DOM Storage and IndexedDB by Rajasekharan Vengalil
05:00 - 05:15 Closing Note 


Register

Tuesday, May 3, 2011

India's Map according to Google Analytics






See the way Kashmir and Arunachal Prasesh is depicted in the map. This map hurts my national pride. I think it is time to ban Google in India.

Saturday, April 30, 2011

Microsoft WebCamps May 5 - June 30

Exclusive one day event on Microsoft Technologies at Mumbai, Chennai, Bangalore, Hydarabad and Pune.

http://www.microsoft.com/india/events/webcamps/default.aspx

Thursday, April 21, 2011

Microsoft Windows Azure Camp - 30th April - 2011

Zenith Hall, UST Global, Bhavani,Technopark, Trivandrum, Kerala

Agenda
Cloud Computing and Azure Overview

Azure Architecture

Azure Management Portal

Services and Tools Needed

Create and debug Azure Application

Deploy application in Azure

Lunch Break

Moving ASP.NET application to Azure

Moving SQL Express database to Azure SQL

Windows Azure App Fabric Cache


Register

Monday, April 18, 2011

WCF RIA Services with Silverlight 4

Developing n-tier application with Silverlight in the earlier version was too tedious and error prone. You have to create a WCF Service, tweak web.conf, expose the functionality as WebMethods and web reference to WCF Service from Silverlight project, after adding a new functi0nality in WCF update the service reference in Silverlight project. The list goes on and on.

WCF RIA Service makes it super easy developing n-tier business applications with Silverlight. WCF RIA Services also comes with built in Validation, Authentication and Authorization service.

I have installed Silverlight 4. In the New Project dialog you will see lot more options.  I am starting a Silverlight Application, Silverlight  Business Application I will take up in another blog and click OK.


Following is the script of the AirLines database which I will be using as example.

In the next dialog select Enable WCF RIA Service.


A Silverlight Solution comprises of two project one an Asp .Net Project and another the client Silverlight project.
I am creating an Ado .Net Entity Data Model for connecting to AirLines database in the Web Project.

Run the project. Add a Domain Service Class to the Web Project.

In the Add New Domain Service Class dialog you can see all the tables selected in the Ado .Net Entity Data Model. Check Enable Editing so that it will generate CUD (Create Update Delete) code.


Again run the project so that the Domain Service class will automatically generate the proxy which you can use from Silverlight.
Now I am ready consuming the Domain Service from Silverlight.

My intention is the show the contents of Locations table inside an DataGrid. I am also filling a ComboBox with LocationNames.
using SilverlightRiaShalvin.Web;

DomainService1 context = new DomainService1();
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
   dataGrid1.ItemsSource = context.Locations;
   comboBox1.ItemsSource = context.Locations;
   comboBox1.DisplayMemberPath = "LocationName";
   comboBox1.SelectedValuePath = "Locationid";
   context.Load<Location>(context.GetLocationsQuery());
}

Here I am extracting the LocationId of the selected Location.
private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
   MessageBox.Show(comboBox1.SelectedValue.ToString());
} 

Here the code for inserting a value to Location Table.
private void button1_Click(object sender, RoutedEventArgs e)
{
  var Loc = new Location{LocationName = "Trivandrum"};
  context.Locations.Add(Loc);
  context.SubmitChanges();
  MessageBox.Show("Record saved");
}

 Silverlight Business Application Air Lines Project

Now let's take up the AirLines project.
CREATE TABLE dbo.Locations(
    LocationId int IDENTITY(1,1) PRIMARY KEY NOT NULL,
    LocationName varchar(20),
    Latitude numeric(6, 2),
    Longitude numeric(6, 2),
    Description varchar(50))
GO

CREATE TABLE dbo.Flight(
    FlightId int IDENTITY(1,1) NOT NULL,
    FlightNo varchar(10),
    FromLocationId int,
    ToLocationId int,
    ArrivalTime varchar(10),
    DepartureTime varchar(10),
    NoofBusSeats int,
    NoofEcoSeats int)
GO

CREATE TABLE dbo.FlightTrans(
    TransId int IDENTITY(1,1) NOT NULL,
    TransDate datetime ,
    UserName varchar(20) ,
    FlightId int,
    EcoSeats int,
    BusSeats int)
GO

CREATE TABLE dbo.FlightStatus(
    FlightDetailId int IDENTITY(1,1) NOT NULL,
    Flightid int,
    TotalSeats int,
    ExecutiveSeats int,
    BuisnessSeats int,
    FlightDate datetime,
    BookedExecutiveSeats int,
    BookedBusinessSeats int) 
GO

CREATE TABLE dbo.FlightRate(
    FlightRateId int IDENTITY(1,1) NOT NULL,
    FlightId int,
    BusStdRate numeric(8, 2),
    EcoStdRate numeric(8, 2))
GO

Along the way I will also demonstrate a few Visual Studio 2010 features related to Silverlight and WPF.
I am starting a new Business Applicaiton Project. WCF Ria Services will be automatically added when you select Business Application Project.


 I will get a project similar to new Asp .Net Web Site Project in Visual Studion 2010. It has a good navigation structure, nice look and feel and a few HyperlinkMenus to start with.
Let's start by changing the title of the project. It has an inbuilt style set through Silverlight Binding. Do refer my blog Silverlight 4/Silverlight for Windows Phones/WPF 4 DataBinding with Visual Studio 2010

if you want to want to learn more about about Silverlight batabinding.
To switch off the Binding of the TextBlock that holds the Application name go to properties window click on the icon next to the Text property in the dialog select Reset settings. Then type your heading.



Like wise I am changing the Content property of Hyperlink buttons to Location and Flights respectively.

 I am using Silverlight Child Window in this project. I am adding a Silverlight Child Window to the project selecting Silverlight Project from the Solution Explorer. As you know two projects will be created when you start new Silverlight project, Silverlight Project and an Asp .Net project for hosting the Silverlight Project. Earlier in the blow we saw adding Entity Data Model and Domain Service Class to the Asp .Net Project.

Insert Location
Location table holds the information about a Location.  This table is referenced by Flights Table.
Here is the Xaml of the frmLocations Silverlight Child Window.


<Grid x:Name="LayoutRoot" Margin="2">
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <sdk:Label Height="28" HorizontalAlignment="Left" Margin="21,34,0,0" Name="label1" VerticalAlignment="Top" Width="120" Content="Location Name" />
    <sdk:Label Height="28" HorizontalAlignment="Left" Margin="21,70,0,0" Name="label2" VerticalAlignment="Top" Width="120" Content="Latitude" />
    <sdk:Label Height="28" HorizontalAlignment="Left" Margin="21,106,0,0" Name="label3" VerticalAlignment="Top" Width="120" Content="Longitude" />
    <TextBox Height="23" HorizontalAlignment="Left" Margin="118,26,0,0" Name="txtLocation" VerticalAlignment="Top" Width="120" />
    <TextBox Height="23" HorizontalAlignment="Left" Margin="118,62,0,0" Name="txtLatitude" VerticalAlignment="Top" Width="120" />
    <TextBox Height="23" HorizontalAlignment="Left" Margin="118,98,0,0" Name="txtLongitude" VerticalAlignment="Top" Width="120" />
    <Button Content="Save" Height="23" HorizontalAlignment="Left" Margin="118,161,0,0" Name="btnSave" VerticalAlignment="Top" Width="75" Click="btnSave_Click" />
</Grid>


Add Entity Data Model and Domain Data Service class as demonstrated in the first part of the blog.


using ShalvinAirlines.Web;

 AirLines context = new AirLines();

private void btnSave_Click(object sender, RoutedEventArgs e)
{
    decimal intLatitude = decimal.Parse(txtLatitude.Text);
    decimal intLongitude = decimal.Parse(txtLongitude.Text);
    var Loc = new Location { LocationName = txtLocation.Text, Latitude = intLatitude, Longitude = intLongitude };
    context.Locations.Add(Loc);
    context.SubmitChanges();
    MessageBox.Show("Location saved");
}
Numeric data type in Sql Server will be mapped to decimal data type in .Net.

Insert Flight

<Grid x:Name="LayoutRoot" Margin="2">
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <sdk:Label Height="28" HorizontalAlignment="Left" Margin="72,61,0,0" Name="label1" VerticalAlignment="Top" Width="120" Content="From Location" />
    <ComboBox Height="23" HorizontalAlignment="Left" Margin="181,54,0,0" Name="cboFrom" VerticalAlignment="Top" Width="120" />
    <sdk:Label Content="To Location" Height="28" HorizontalAlignment="Left" Margin="72,103,0,0" Name="label2" VerticalAlignment="Top" Width="120" />
    <ComboBox Height="23" HorizontalAlignment="Left" Margin="181,97,0,0" Name="cboTo" VerticalAlignment="Top" Width="120" />
    <sdk:Label Height="28" HorizontalAlignment="Left" Margin="72,139,0,0" Name="label3" VerticalAlignment="Top" Width="120" Content="Arrival Time" />
    <TextBox Height="23" HorizontalAlignment="Left" Margin="181,131,0,0" Name="txtArrivalTime" VerticalAlignment="Top" Width="120" />
    <sdk:Label Height="28" HorizontalAlignment="Left" Margin="72,175,0,0" Name="label4" VerticalAlignment="Top" Width="120" Content="Departure Time" />
    <TextBox Height="23" HorizontalAlignment="Left" Margin="181,167,0,0" Name="txtDepartureTime" VerticalAlignment="Top" Width="120" />
    <sdk:Label Height="28" HorizontalAlignment="Left" Margin="72,211,0,0" Name="label5" VerticalAlignment="Top" Width="120" Content="No. Economy Seats" />
    <TextBox Height="23" HorizontalAlignment="Left" Margin="181,203,0,0" Name="txtNoEconomySeats" VerticalAlignment="Top" Width="120" />
    <sdk:Label Content="No. Business Seats" Height="28" HorizontalAlignment="Left" Margin="72,241,0,0" Name="label6" VerticalAlignment="Top" Width="120" />
    <TextBox Height="23" HorizontalAlignment="Left" Margin="181,233,0,0" Name="txtNoBusinessSeats" VerticalAlignment="Top" Width="120" />
    <Button Content="Save" Height="23" HorizontalAlignment="Left" Margin="181,277,0,0" Name="btnSave" VerticalAlignment="Top" Width="75" Click="btnSave_Click" />
    <sdk:Label Height="28" HorizontalAlignment="Left" Margin="72,26,0,0" Name="label7" VerticalAlignment="Top" Width="120" Content="Flight No." />
    <TextBox Height="23" HorizontalAlignment="Left" Margin="181,18,0,0" Name="txtFlightNo" VerticalAlignment="Top" Width="120" />
</Grid>


using ShalvinAirlines.Web;

AirLines context = new AirLines();
private void ChildWindow_Loaded(object sender, RoutedEventArgs e)
{
    cboFrom.ItemsSource = context.Locations;
    cboFrom.DisplayMemberPath = "LocationName";
    cboFrom.SelectedValuePath = "LocationId";

    cboTo.ItemsSource = context.Locations;
    cboTo.DisplayMemberPath = "LocationName";
    cboTo.SelectedValuePath = "LocationId";
    context.Load(context.GetLocationsQuery());
}

private void btnSave_Click(object sender, RoutedEventArgs e)
{
    int intFromId = Int32.Parse(cboFrom.SelectedValue.ToString());
    int intToId = Int32.Parse(cboTo.SelectedValue.ToString());
    int intNoBusSeats = Int32.Parse(txtNoBusinessSeats.Text);
    int intNoEcoSeats = Int32.Parse(txtNoEconomySeats.Text);
    var Fl = new Flight { FlightNo = txtFlightNo.Text, 
        FromLocationId = intFromId, 
        ToLocationId = intToId, 
        ArrivalTime =  txtArrivalTime.Text,
    DepartureTime = txtDepartureTime.Text,
    NoofBusSeats=intNoBusSeats,
    NoofEcoSeats= intNoEcoSeats };

    context.Flights.Add(Fl);
    context.SubmitChanges();
    MessageBox.Show("Flight inserted");
}
First I filled the Combo Boxes with the LocationName and Set the SelectedValuePath to LocationId so that I an extract the LocationId of the Selected Item.




Booking Module

xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" Loaded="ChildWindow_Loaded">
<Grid x:Name="LayoutRoot" Margin="2">
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <sdk:Label Content="Flight" Height="28" HorizontalAlignment="Left" Margin="10,10,0,0" Name="label1" VerticalAlignment="Top" Width="120" />
    <TextBox Height="23" HorizontalAlignment="Left" Margin="103,81,0,0" Name="txtEconomySeats" VerticalAlignment="Top" Width="120" />
    <ComboBox Height="23" HorizontalAlignment="Left" Margin="103,10,0,0" Name="cboFlight" VerticalAlignment="Top" Width="120" />
    <sdk:Label Content="Date" Height="28" HorizontalAlignment="Left" Margin="10,45,0,0" Name="label2" VerticalAlignment="Top" Width="120" />
    <sdk:DatePicker Height="23" HorizontalAlignment="Left" Margin="103,45,0,0" Name="dtpDate" VerticalAlignment="Top" Width="120" />
    <sdk:Label Content="Economy Seats" Height="28" HorizontalAlignment="Left" Margin="10,82,0,0" Name="label3" VerticalAlignment="Top" Width="120" />
    <sdk:Label Content="Business Seats" Height="28" HorizontalAlignment="Left" Margin="10,131,0,0" Name="label4" VerticalAlignment="Top" Width="120" />
    <TextBox Height="23" HorizontalAlignment="Left" Margin="103,123,0,0" Name="txtBusSeats" VerticalAlignment="Top" Width="120" />
    <Button Content="Book" Height="23" HorizontalAlignment="Left" Margin="103,188,0,0" Name="btnBook" VerticalAlignment="Top" Width="75" Click="btnBook_Click" />
</Grid>

AirLines context = new AirLines();
private void ChildWindow_Loaded(object sender, RoutedEventArgs e)
{
    cboFlight.ItemsSource = context.Flights;
    cboFlight.DisplayMemberPath = "FlightNo";
    cboFlight.SelectedValuePath = "FlightId";

    context.Load(context.GetFlightsQuery());
}

private void btnBook_Click(object sender, RoutedEventArgs e)
{
    DateTime dt = DateTime.Parse(dtpDate.SelectedDate.ToString());
    int intEcoSeats = Int32.Parse(txtEconomySeats.Text);
    int intBusSeats = Int32.Parse(txtBusSeats.Text);
    int intFlightId = Int32.Parse(cboFlight.SelectedValue.ToString());

    var Book = new FlightTran { TransDate = dt, UserName = GlobalClass.UserName, 
        FlightId = intFlightId, EcoSeats = intEcoSeats, BusSeats = intBusSeats };
    context.FlightTrans.Add(Book);
    context.SubmitChanges();
    MessageBox.Show("Booking completed");
}

Saturday, April 16, 2011

BarCamp Kerala 10

10th edition of BarCamp Kerala will be held at SCMS B-School at Kalamaserry on 8th May 2011.

For more details visit http://www.barcampkerala.org

Wednesday, April 13, 2011

Malayalam FireFox 4 Experience

Today I installed Malayalam FireFox 4. Here are few Screen Shots.







Saturday, February 19, 2011

Razor View Engine and Visual Studio

The inspiration for this blog on Razor was the Web Camp conducted by Microsoft Evangelists Nahas Mohammed  and Ramaprasanna Chellamuthu on February 18 at Kochi. We received great insight into Razor View Engine and Web Matrix.
A few of the audience were invited to the stage and it was more of an interactive Code camp.


I am using Visual Web Developer 2010, a free tool from Microsoft for developing Asp .Net Applications. All the examples will work in Visual Studio.  I have already installed Asp .Net MVC 3 in my machine.

Visual Studio 2010 / Visual Web Developer 2010 comes will Intellisense and debugging support for Razor. Unlike Asp .Net Web Forms in Razor the Visual Interface is defined using HTML.

I am starting an Empty Web Site and Adding an Empty Razor Page.







@{
    var strName = "";
    if(IsPost)
    {
        strName = "Hello welcome to Razor"
    }
    
}
<form method=post>
<p>
@strName
</p>
<input id="Submit1" type="submit" value="submit" />
</form>






Inside a block each statement should end with a semicolon. Inside html you can call the memory variable using @ symbol. There semicolon should not be present.

We are checking a form post using IsPost. On Clicking the Submit buttom a Form POST will occur after that the memory variable will be assigned the Hello message and that message will be dispayed.



Using can use Html Tab in the Toolbox to add Html tags to the form.


You can see that the auto completion feature is available.

@{
    var strName = "";
    if(IsPost)
    {
        strName = "Hello " + Request["txtName"];
    }
 }
<form method=post>
<p>
@strName
</p>
Name 
<input Name="txtName" type="text" />
<br />
<input id="Submit1" type="submit" value="submit" />
</form>



In the above example we extracting the value of textbox using Request.








@{
    var sum = 0;
    if(IsPost)
    {
        sum = Request["txtValue1"].AsInt() + Request["txtValue2"].AsInt();
           
    }
    
}

<form method =post>
<p>
@sum
</p>
Value 1<input Name = "txtValue1" type="text" />
</br>
Value 2<input Name = "txtValue2" type="text" />
</br>
<input id="Submit1" type="submit" value="submit" />
</form>

AsInt() is used to convert the value to Integer.



Session
//Session.cshtml
@{
    Session["Name"] =  "Shalvin"; 
}

<form method =post>
<a href = "@Href("Welcome")">Welcome</a>
</form>





//Welcome.cshtml
@{
var strName = "Hello " + Session["Name"];
}




@strName





Href method is used to create paths to resources like Web pages.
In the first page we are defining the session variable and in the second page we extracting the value of Session variable.


Entity Framework
I am creating an Entity Data Model is shown in the figure



@{
    var context = new ContactManagementModel.ContactManagementEntities();

    var Grps = context.ContactGroups;

    var gd = new WebGrid(Grps);
}

<html>
<body>
 @gd.GetHtml();
</body>
</html>






WebGrid helper can be used to display day is a tabular manner.





@{
    var context = new ContactManagementModel.ContactManagementEntities();
  var strMessage = "";
    if(IsPost)
    {
    var Grp = new ContactManagementModel.ContactGroup{GroupName = Request["txtGroupName"]};

    context.AddToContactGroups(Grp);
    context.SaveChanges();
    strMessage = "Record Saved";
    }
        
}

<form method = "post">
<p>
@strMessage
</p>
Group Name 
<input Name = "txtGroupName" type="text" />
</br>
    <input id="Submit1" type="submit" value="submit" />
</form>

Thursday, February 3, 2011

Microsoft Web Camps on February 18, Kochi

Venue : ABAD PLAZA
M.G Road, Cochin-682 035


09:00am - 10:00amREGISTRATION
10:00am - 10:30amOpening Keynote  -  Nahas Mohammed & Ramaprasanna Chellamuthu
10:30am - 11:30amIntroduction to WebMatrix - Nahas Mohammed
11:30am - 12:30pmForms and Data Access - Nahas Mohammed
12:30pm - 01:30pmLUNCH BREAK
01:30pm - 02:30pmHelpers and Publishing - Ramaprasanna Chellamuthu
02:30pm - 03:30pmDotNetNuke on WebMatrix - Ramaprasanna Chellamuthu
03:30pm - 04:00pmAudience Q&A and Closing Note - Nahas Mohammed & Ramaprasanna Chellamuthu

RSVP : 080-4089 7010,
+91-96636 82120

mswebcamps@end2end.in

Saturday, January 15, 2011

Asp .Net Mvc with Entity Framework 4










































































public ActionResult Index()
{
var Grp = context.ContactGroups;
return View(Grp);
}







//
// GET: /Home/Create

public ActionResult Create()
{
return View();
}

//
// POST: /Home/Create

[HttpPost]
public ActionResult Create(ContactGroup Grp)
{
if (ModelState.IsValid)
{
try
{
context.AddToContactGroups(Grp);
context.SaveChanges();
return RedirectToAction("Index");
}
catch
{
return View(Grp);
}
}
else
{
return View(Grp);
}
}





//
// GET: /Home/Edit/5

public ActionResult Edit(int id)
{
var Grp = context.ContactGroups.SingleOrDefault(x => x.GroupId == id);
return View(Grp);
}

//
// POST: /Home/Edit/5

[HttpPost]
public ActionResult Edit(int id, FormCollection collection)
{
var Grp = context.ContactGroups.SingleOrDefault(x => x.GroupId == id);

try
{
UpdateModel(Grp, collection.ToValueProvider());
context.SaveChanges();

return RedirectToAction("Index");
}
catch
{
return View();
}
}






//
// GET: /Home/Delete/5

public ActionResult Delete(int id)
{
var Grp = context.ContactGroups.SingleOrDefault(x => x.GroupId == id);
return View(Grp);
}

//
// POST: /Home/Delete/5

[HttpPost]
public ActionResult Delete(int id, FormCollection collection)
{
var Grp = context.ContactGroups.SingleOrDefault(x => x.GroupId == id);

try
{
context.DeleteObject(Grp);
context.SaveChanges();

return RedirectToAction("Index");
}
catch
{
return View();
}
}