ASP.NET MVC: How to 'model bind' a non html-helper element

后端 未结 2 1683
轮回少年
轮回少年 2021-02-02 16:21

Could you tell me a way(s) that I can bind a model property to a html-element, created without using html helper?

In other words to a plain html element

2条回答
  •  时光说笑
    2021-02-02 16:39

    Just give it a name:

    
    

    and then inside your controller action simply have an argument with the same name:

    public ActionResult Process(string foo)
    {
        // The foo argument will contain the value entered in the 
        // corresponding input field
    }
    

提交回复
热议问题