Infolink

 

Search This Blog

Showing posts with label asp.net with mvc. Show all posts
Showing posts with label asp.net with mvc. Show all posts

Nov 29, 2012

How to create MVC (model view controller) views faster by using HTML helper classes

MVC using HTML helper classes 

<table width="50%" runat="server" id="tbl1">
    <tr>
    <td>Student Id:</td>
    <td><asp:TextBox runat="server" ID="txt1"></asp:TextBox></td></tr>
    <tr>
    <td>Student Name:</td>
    <td><asp:TextBox runat="server" ID="txt2"></asp:TextBox></td></tr>
    <tr>
    <td>Student Percentage:</td>
    <td><asp:TextBox runat="server" ID="txt3"></asp:TextBox></td></tr>
    <tr>
    <td colspan="2" align="center"><asp:Button ID="Button1" runat="server" Text="Button" /></td>
    </tr>
</table>


How to pass data from controllers to views in ASP.NET MVC ?

The controller gets the first hit and loads the model. Most of the time we would like to pass the model to the view for display purpose.

As an ASP.NET developer your choice would be to use session variables, view state or some other ASP.NET session management object.

How to create a simple ASP.NET MVC data entry screen?

Creating simple MVC data entry screen

Every project small or big has data entry screens. In this lab we will create a simple customer data entry screen as shown in the below figure.



As soon as the end user enters detail and submits data it redirects to a screen as shown below. If he enters amount less than 100 it displays normal customer or else it displays privileged customer.

Basic MVC

The Model

Models are the main component of your app, which is usually; what is stored and retrieve from the database, in our app, it will the tweet info and text.

The View

Views are the date in formatted form, delivered to the user. Here it will be the HTML pages.

The Controller

Controllers are the components that respond to all user requests, decide the appropriate response; which might be render a view, redirect to other URI or many other things.

Pros and Cons
  • Pros
It has many pros, but these are the most remarkable:
  1. Full control over the HTML, CSS, and JavaScript code, helping you to write clean, standards-compliant markup
  2. It's Extensible which means that you can use a default component, or reconfigure it, or even use another component
  3. HTTP friendly, it gives you total control over the requests passing between browser and server
  4. Testability of MVC makes it simple to unit test the logic that is specific to a page, by testing controller methods
  • Cons
It does not really have many cons compared to its pros:
  1. The lake of drag and drop component in WebForms, despite that JQuery and other JavaScipt library overcome this problem
  2. It's not as easy as WebForms, you should understand the role of each component individually and all of them together.

Nov 28, 2012

How to create a simple model in ASP.NET MVC and display the same?(PART-4)

Step1:- Create a simple class file

The first step is to create a simple customer model which is nothing but a class with 3 properties code, name and amount. Create a simple ASP.NET MVC project, right click on the model folder and click on add new item as shown in the below figure.


Nov 26, 2012

ASP.NET MVC (PART-3)

MVC stands for "Model-View-Controller", which is a very old (but still very useful) design pattern. This design pattern will split your application in 3 different parts ("model", "view", "controller"). "Seperation of concern" is one of it´s main benefits.
Related Posts Plugin for WordPress, Blogger...