简体   繁体   中英

all controls of an content form of any type of controls in asp.net

how to make Readonly All controls of form of any type of control on the basis of certain condition in asp.net we want button should dont be disable but can be active.it should be generic way to do it Actually i have an master page in which i got an button while we got other controls like Repeater and Textbox's dropdownlist radio button list and check box list in the content pages,

i have used foreach loop in the master page to find the controls in content page but and mark them readonly so that no1 can changes the save values of the control just i dont want button should be get disable but am nt able to achieve this please help me am new to asp.net i am java developer but working on asp.net now a days

You can do this using css. Add a css class to all controls in the page.

A question similar to your question. This may help you.

I assume you want controls to be disabled except buttons

foreach(WebControl c in Page.Controls)
{
    if(c is TextBox || c is DropdownList)
    {
        c.Enabled = false;
    }
 }

This does not stop user from changing the behaviour of the rendered controls from the page. It should still be possible for user to inspect element and modify the properties.

You need to check from codebehind to ignore values from controls that you don't want edited.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM