C# .NET - how to enable or disable the textbox within DetailsView when we are clicking the checkbox in the DetailsView

Asked By umesh lohani on 10-Feb-09 06:19 AM
hi folks,
Tell me how to disable or enable the textBox for editing when we are clicking the checkbox in the details view.
i tried with find control but didn't work.
Plz tell me with examples.
Thanks

check - Santhosh N replied to umesh lohani on 10-Feb-09 06:40 AM

You can have a javascript function to do this and here is a sample how to call javascript function in checkbox click event ..

http://www.telerik.com/community/forums/aspnet/grid/checkbox-inside-a-radgrid-calling-javascript-as-well-as-serverside-function.aspx

set the disabled property of the textbox to true in the javascript event..

here is the sample javascript code - Venkat K replied to umesh lohani on 10-Feb-09 07:04 AM

Here the textbox is on the form,

Changes: use document.getElementByID("dtvwtxtbox").disabled=false

where dtvwtxtbox is the id of textbox inside detailsview.

<html>
<head>
<title>Untitled</title>
<script>
function enable()
{
document.myForm.textbox.disabled = false;
}
</script>
</head>
<body>
<form name="myForm">
<input type="checkbox" onclick="enable()">&nbsp;&nbsp;Enable<br><br>
<input type="text" name="textbox" value="Hello World" disabled>
</form>
</body>
</html>