Home Set property "readonly" for @Html.TextBoxFor( ) dynamically based on fetched information from db
Reply: 0

Set property "readonly" for @Html.TextBoxFor( ) dynamically based on fetched information from db

user611
1#
user611 Published in June 22, 2018, 11:30 am

I have multiple Textboxes defined using @Html.TextBoxFor(). Now I want some of them to be only "readonly" and some of them editable, based on the role of user accessing the page.

I have tried using the following

@Html.TextBoxFor(f => f.VSSLabel, new { style = "height:19px", @Value = @ViewBag.fetchf.VSSLabel, @readonly="readonly" })

Is there any way that we can set @readonly="false" and it becomes editable, or any other approach so I switch it to "readonly" and editable based on the Value stored in a ViewBag variable coming from controller?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.349248 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO