开发者

MS MVC 3 custom html helper that recieve as parameter the model?

开发者 https://www.devze.com 2023-03-09 06:32 出处:网络
I\'ve written a custom html helper in MVC 3 that receive as a 开发者_开发知识库parameter the model my view is based on. What I\'m wondering is: can a custom helper access the model without receiving i

I've written a custom html helper in MVC 3 that receive as a 开发者_开发知识库parameter the model my view is based on. What I'm wondering is: can a custom helper access the model without receiving it as a parameter? Is there any way to avoid calling it like this: @html.MyCustomHelper(Model)?


you can use the ViewData property of HtmlHelper to access the model

helper.ViewData.Model
0

精彩评论

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