I'm trying to disable some controls on my Aspx page but can't get it working. I've tried both Javascript and JQuery so I know I must be doing something simple wrong.
Here's what I have atm and I know that it's definitely entering both functions when I want them to because I've stuck in alerts to tell me so. However the controls remain enabled always!
<script language="javascript" type="text/javascript">
function fun1(){
var input = $('#txtDocs');
input.removeAttr('disabled');
}
function fun2() {
var input = $('#txtDocs');
input.attr('disabled', 'disabled');
}
And the control itself;
<p>
<asp:TextBox ID="txtDocs" runat="server" Width="218px"
Height="75px" TextMode="MultiLine" MaxLength="40"/>
</p>
I've also tried swapping out the code in both functions for various versions of the following;
document.getElementById("txtDocs").enabled = true;
document.getElementById("txtDocs").attributes.enabled = true;
document.getElementById("txtDocs").disabled = false;
No good though. What am I doing wrong?
UPDATE
current code;
function fun1(){
alert("1 enable");
$('#txtDocs').removeAttr('disabled');
alert("2 enable");
}
function fun2() {
alert("1 disable");
$('#txtDocs').prop('disabled', true);
alert("2 disable");
}
<asp:TextBox ID="txtDocs" runat="server" Width="218px" ClientIDMode="Static"
Height="75px" TextMode="MultiLine" MaxLength="40"/>
Still no good :/ I'm only seeing alert("1 disable")
, alert("1 enable")
and alert("2 enable")
so not getting through fun2...
NOTE
Debugged into my code and just noticed that during run time my Textbox is actually a Textarea. Any significance? Also it's ID will have the usual "ctl00_MainContentPlaceHolder_" tagged onto the start.