开发者

Retrieve value posted from MVC3 aspx view

开发者 https://www.devze.com 2023-04-02 14:12 出处:网络
views are different from web forms? I can\'t seem to access my server controls on the view. With a webform you can retrive the value of a textbox as <name>.Text as long as it\'s a server contro

views are different from web forms? I can't seem to access my server controls on the view. With a webform you can retrive the value of a textbox as <name>.Text as long as it's a server control. How am I supposed to do this in MVC3? I'm using aspx views.

I know 开发者_开发技巧the value is in the Request.forms collection but isn't there a less ugly way to retrive the value of a textbox.


I assume you mean accessing the values in the action, not in the view.

There are several ways, one is by accepting them as parameters of your action method (model binding; another sample), the other is manually read Request.Form as you suggested.

But this is a very short answer. You must learn MVC basics before you try to dive into the water and code. In MVC, the chance that you'd do the wrong thing (against MVC's architecture) is very high if you don't learn the theoretical stuff before.

0

精彩评论

暂无评论...
验证码 换一张
取 消