Thursday, September 9, 2010

First MVC 2 Application with Visual Studio 2010

Creating your First MVC Application with Visual Studio 2010

Eg: Follow the following steps.

  • Create an empty MVC 2 web application.


  • Add a controller named HomeController and write the following method.
public string Index()
{
  return "My first MVC Application";
}

  • Run the application.

The above application just returns a string value. We dont have any view. The browser will display only a string.

ASP.NET MVC Folder Conventions

ASP.NET MVC Folder Conventions


App_Data : Contains database files. For example, the App_Data folder might contain a local instance of a SQL Server Express database.

Content : Contains static content such as images and Cascading Style Sheet files.

Controllers : Contains ASP.NET MVC controller classes.

Models : Contains ASP.NET MVC model classes.

Scripts : Contains JavaScript files including the ASP.NET AJAX Library and jQuery.

Views : Contains ASP.NET MVC views.

Introduction to MVC 2 with Visual Studio 2010

Microsoft MVC 2 in Visual Studio 2010


The Microsoft ASP.NET MVC framework is Microsoft’s newest framework for building web applications. The ASP.NET MVC framework was created to support pattern-based software development. In other words, the framework was designed to make it easier to implement software design principles and patterns when building web applications.

An MVC application, a Model View Controller application, is divided into the following three parts:

• Model: An MVC model contains all of an application’s logic. The model includes all of an application’s validation logic, business logic, and data access logic.

• View: An MVC view contains HTML markup and view logic.

• Controller: An MVC controller contains control-flow logic. An MVC controller interacts with MVC models and views to control the flow of application execution. which handle incoming requests, perform operations on the domain model, and choose a view to render back to the user

Tuesday, September 7, 2010

Adding a VideoBrush in Silverlight

Using a VideoBrush in Silverlight Application


VideoBrush elements are very similar to the ImageBrush. Instead of an image, they define a video MediaElement that is applied as a brush. You can apply them to the properties of Silverlight controls the same way that the ImageBrush is applied.

To apply a VideoBrush to a Silverlight control, you need to define the VideoBrush element just as you do with an ImageBrush. However, different from an ImageBrush, you need to set a SourceName property that points to the x:Name of the MediaElement. Therefore, you also need to define a MediaElement separate from the Silverlight control. If you do not want the video to be displayed outside of the Silverlight control, set the Opacity property of the MediaElement to 0.

Eg:

< MediaElement Source="first.wmv"
x:Name="movie"
Opacity="0"/ >


< TextBox Height="100" Width="150" >
< TextBox.Background >
< VideoBrush SourceName="movie" Stretch="UniformToFill"/ >
< /TextBox.Background >
< /TextBox >

Adding an ImageBrush in Silverlight

Using an ImageBrush in Silverlight Application


ImageBrush elements are similar to the SolidColorBrush. Instead of a solid color, they define an image that is applied as a brush. You can apply them to the properties of Silverlight controls the same way that the SolidColorBrush is applied.

To apply an ImageBrush to a Silverlight control, you need to define the ImageBrush element and set the ImageSource property to an image that has been added to the project. You will likely want to set the Stretch property so that the image appears appropriately in the control.

Eg:

< TextBox Height="200" Width="150" >
< TextBox.Background >
< ImageBrush ImageSource="jobin.jpg"/ >
< /TextBox.Background >
< /TextBox >