开发者

How to add a <T> type argument to a function called from an MVC3 Razor View?

开发者 https://www.devze.com 2023-04-04 14:50 出处:网络
I\'ve written a function to output an enum as RadioButtons in a group (based on code answers found on here...blatantly stolen!)

I've written a function to output an enum as RadioButtons in a group (based on code answers found on here...blatantly stolen!)

However, the function takes a type argument - and I can't work out how to call it from the View?

I've tried the two snippets below...the first works correctly, but doesn't output anything, and I can't work out how to get the second to t开发者_StackOverflow中文版ake ?

@{
    Html.RadioButtonForEnum<RuleType>("Rule");   
}

@Html.RadioButtonForEnum<RuleType></RuleType> <--this gets autocompleted for me!

I've a feeling this is going to be simple...!


Sounds like you need to make your code block explicit. Try:

@(Html.RadioButtonFor<RuleType>("Rule"))
0

精彩评论

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