C# Tutorials and offshore development in India
Tutorials Resources Forum Reviews Communities Interview Jobs Projects Training Videos


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...


Birthday Greetings
Learn Windows 7: How to remove Recent Items from startup menu in windows 7   In this article ,I will explain how to remove and add recent "Recent Items" from windows 7 startup menu



Forums » .NET » ASP.NET »

Disable textbox in ASP.NET


Posted Date: 15 Nov 2005      Posted By:: Nithya    Member Level: Silver    Member Rank: 0     Points: 2   Responses: 2



When my page is loaded I want my textbox to be disabled and then to be enabled when we press a button. I tried textbox1.enabled=false in PageLoad and then set textbox properties(Enabled=false). But it's of no use. What to do? How to disable the textbox? I want the coding for asp.net.





Responses

Author: Brainstorming Guy     Member Level: Diamond      Member Rank: 74     Date: 15/Nov/2005   Rating: 2 out of 52 out of 5     Points: 2

Hai,
Just add the javascrit in the <HEAD> tag

<script>
function disableText()
{
document.getElementById("TextBox1").disabled=true;
}
function enableText()
{
document.getElementById("TextBox1").disabled=false;
return false;
}
</script>

In the page load call the function like
<body MS_POSITIONING="GridLayout" onload="return disableText();">
This will call the javascript function to disable the text box. Where TextBox1 is the textbox.
In the page load event of the page give the following code
Button1.Attributes.Add("onClick", "return enableText();")
When you test the application, while loading the textbox will be disable and when you click the button, the textbox will be enabled.

Regards,
Brainstorming Guy aka Venkatarajan A

Regards,
Brainstorming Guy aka Venkatarajan A

BEEN THERE. DESTROYED THAT.



Author: antogladwin     Member Level: Silver      Member Rank: 0     Date: 13/Jun/2008   Rating: 2 out of 52 out of 5     Points: 2

hi,
nice scripts.keep it up...



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Previous : Validation Controls
Return to Discussion Forum
Post New Message
Category: ASP.NET



About Us    Contact Us    Privacy Policy    Terms Of Use