Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Dropdownlists(unselectable) in html (vb.net)

Options
  • 14-03-2007 1:23pm
    #1
    Registered Users Posts: 500 ✭✭✭


    I am having a bit of a problem with a dropdown list. using vb.net - but ts just basic html stuff(hopefully)
    anyway i have a display page for my data - and based on the users access_level i allow them to modify the data or just read it.

    textboxes are easy
    txtbox1.readonly=true

    dropdownlists ???

    how do i make the user unable to select different values on these?

    Any tips or workarounds?


Comments

  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    Do you need to make the entire select box disabled or individual elements ?

    The attribute "disabled" will disabled the box.

    <select disabled></select>

    Firefox and Mozilla support disabling an option.

    <option disabled></option>

    Oddly enough, Internet Explorer screws it up; it'll correctly get the "disabled" attribute for the option, but it won't disable it :rolleyes:

    It looks like you'll need to do a check for "onchange" and code the options that you need to disable.

    function setOption(t) {
    if (t.options[t.selectedIndex].getAttribute("disabled")=="true") {
    alert("Please select a different option");
    return
    }
    }

    I'm not sure what the vb.net syntax to do the above is.....could never see the sense in how vb hacks its own syntax into HTML, especially when half the code that it generates breaks in other browsers.


  • Moderators, Science, Health & Environment Moderators Posts: 8,959 Mod ✭✭✭✭mewso


    Well for starters vb doesn't "hack" it's own stuff into the html. At most it embeds javascript or hidden input fields for processing on postback of a page.
    Anyway I think the best solution here is to remove options from the list on the server side before displaying the page to the user. Alot more straight-forward anyway.


  • Registered Users Posts: 500 ✭✭✭warrenaldo


    its ok folks i got it.
    as im new to vb.net i didnt know that this attribute would do this. but its the enabled attribute.

    never knew about it - thanks for the help.


Advertisement