views:

163

answers:

0

Hi,

my problem is the View where the user typed, the validation. I have to take RedirectToAction on the site because on the site upload a file. Thats my code.

My model class

public class Person
{
 [Required(ErrorMessage= "Please enter name")]
 public string name { get; set; } 
}

My View

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MvcWebRole1.Models.Person>" %>

Name

<h2>Information Data</h2>

<%= Html.ValidationSummary() %>

<%using (Html.BeginForm ("upload","Home", FormMethod.Post, new{ enctype ="multipart/form-data" }))  {%>

    <fieldset>
        <legend>Fields</legend>
        <p>
            <label for="name">name:</label>
            <%= Html.TextBox("name") %>
            <%= Html.ValidationMessage("name", "*") %>
        </p>

    </fieldset>
    <% } %>

and the Controller

[AcceptVerbs(HttpVerbs.Post)]
    public ActionResult upload(FormCollection form)
    {


            Person lastname = new Person();

            lastname.name = form["name"];


            return RedirectToAction("Index");
    }

Thx for answer my question In advance