开发者

Read Only asp drop down list

I'm working on an ASP.Net app

I have a drop down that, under some conditions, should be 'read only', that is, the user can't change it but, on a post back its selected value can be read.

Now I know that the readOnly attribute is not available for drop downs so I'm trying to build a method that simulates this

so I wanted to make a javascript function that doesnt let the user 'open' the drop down to select an item. is this possible?

here's the example

function MakeDropDownReadOnly(dropDownId, makeReadOnly){

    var myDropDown = document.getElementById(dropDownId);

    if(makeReadOnly){
        //Block drop down

    开发者_运维问答}
     else{
          //Unblock drop down
     }
}

tks


Make it disabled then in form submit (using JavaScript) enable it again so the value will be sent to the server.

Sample code to enable upon submitting:

document.getElementById("<%=DropDown1.ClientID%>").disabled = false;


Can't you use Enabled="false"?


Have You tried "Enabled" property of the DropDownList?


onfocus="this.blur()" might work to prevent a user to interact with the select.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜