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

user3932
1#
user3932 Published in September 19, 2018, 6:44 pm

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?

share|improve this question

1 Answer 1

active oldest votes
up vote 1 down vote accepted
You need to login account before you can post.

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

© 2016 Powered by mzan.com design MATCHINFO