开发者

Conditional HiddenInputAttribute

开发者 https://www.devze.com 2023-03-01 06:33 出处:网络
I need an attribute in ASP .NET MVC view model, which check the specif开发者_运维问答ied condition (based on another property value) and turn on/off visibility parameter of input control on edit page.

I need an attribute in ASP .NET MVC view model, which check the specif开发者_运维问答ied condition (based on another property value) and turn on/off visibility parameter of input control on edit page.

Something like that:

public string SomeProperty { get; set; }

[ConditionalHidden("SomeProperty", "PropertyValueToMakeConditionTrue")]
public string DependentProperty { get; set; }

Is it possible?


If you need it after page is loaded then you need javascript code.

Else you can use in view

@if(Model.Property == something)
    {
        html
    }

But this is without attribute.

0

精彩评论

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

关注公众号