English 中文(简体)
MVC 向行动方法转移数据
原标题:MVC transfering data from view to action method

我有一种看法,我想当一个纽芬兰被点击时,用文字箱价值的新信息重载同样的观点。 新的信息将载于一个数据库——Im在控制器中这样做。

因此,我认为,我应当从这个角度讲一种行动方法。

但是,我读到,把数据从角度看转移给主计长的做法不好,因为MVC特别为此设计了NOT。

Does someone have an idea how to design this?

最佳回答

Description

http://www.un.org/Depts/DGACM/index_french.htm 主计长。 您可以提出一种形式,并以提交的形式提交您的行动备忘录。

These are fundamentals of ASP.NET MVC, you should learn it.

Sample

<><><>>>>

public class ViewModel
{
    public string SomeProperty { get; set; }
}

View

@model MvcApplication2.Models.ViewModel;

@using (Html.BeginForm())
{
    @Html.TextBoxFor(x => x.SomeProperty)
    <input type="submit" />
}

<Controller with ActionMethods

public class HomeController : Controller
{
    [HttpGet]
    public ActionResult Index()
    {
        return View(new ViewModel());
    }

    [HttpPost]
    public ActionResult Index(ViewModel model)
    {
        // do something with your model
        // load from something from database for example
        return View(model);
    }
}

More Information

问题回答

Where exactly did you read that it s poor practice to transfer data from the view to the controller? You need to transfer some information to the action to signify what data to fetch.

在你的设想中,你可以使用路线价值进行补贴:

@Html.ActionLink("Get Latest", "GetLatest", new { Id = Model.Id })

观点模式有<条码> Id Property for the present view s items.

纽伦点击应表明自己是处理投入的主计长行动的一个吉大港山区行动计划。 管制人员将处理投入,从数据库中收集适当信息,并将这种新数据所收集的观点退回。

该观点应当提及控制人的行动,以便确定吉大港山区行动计划的地址,但其本身并不向控制人传递数据。

认为“意见”没有处理点击,而“意见”只是超文本的模板,而是由客户浏览器处理。

除了上述内容外,为了重载同样的观点,你不妨考虑利用国际独立调查委员会提供的亚克斯功能。 之后,你将不必真正重载整页,而只是页上的一个部分。 http://msdn.microsoft.com/en-us/library/dd3815 3328v=VS.9829.aspx”rel=“nofollow”





相关问题
WebForms and ASP.NET MVC co-existence

I am trying to make a WebForms project and ASP.NET MVC per this question. One of the things I ve done to make that happen is that I added a namespaces node to the WebForms web.config: <pages ...

Post back complex object from client side

I m using ASP.NET MVC and Entity Framework. I m going to pass a complex entity to the client side and allow the user to modify it, and post it back to the controller. But I don t know how to do that ...

Create an incremental placeholder in NHaml

What I want to reach is a way to add a script and style placeholder in my master. They will include my initial site.css and jquery.js files. Each haml page or partial can then add their own required ...

asp.net mvc automapper parsing

let s say we have something like this public class Person { public string Name {get; set;} public Country Country {get; set;} } public class PersonViewModel { public Person Person {get; ...

structureMap mocks stub help

I have an BLL that does validation on user input then inserts a parent(PorEO) and then inserts children(PorBoxEO). So there are two calls to the same InsertJCDC. One like this=>InsertJCDC(fakePor)...

ASP.NET MVC: How should it work with subversion?

So, I have an asp.net mvc app that is being worked on by multiple developers in differing capacities. This is our first time working on a mvc app and my first time working with .NET. Our app does not ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

热门标签