C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » ASP.NET »

Regarding Textarea


Posted Date: 15 Oct 2008      Posted By: varuna akuthota      Member Level: Bronze     Points: 1   Responses: 3



Hi

/*********************
Actually I have one textbox with some default text. When the focus goes to that textbox default text should be empty and ready to enter new text and also color should be changed.

In this case I wanna use GotFocus event but i didnt find it. So please tel me the alternate event.
*********************/

For the above issue i got the answer Thank you.

But If it is Textarea control then??? It doesnt have the property value so where should i enter text and how should i check the value from javascript???

Thanks in advance





Responses

Author: gomathinayagam    15 Oct 2008Member Level: GoldRating: Revenue Score: 0     Points: 0

use javascript to do that. i give here a sample:

<input name="textfield3" type="text" class="textBox" id="textfield3" style="color: #cccccc; width: 129px;"
onfocus="cler()" onblur="addtxt()" value="e-mail:" runat="server" />


java script function


<script language="javascript" type="text/javascript">
function cler(){
if(document.getElementById('<% = textfield3.ClientID %>').value=='e-mail:')
{
document.getElementById('<% = textfield3.ClientID %>').value="";
document.getElementById('<% = textfield3.ClientID %>').style.color="#1c6b99";
}

function addtxt(){
if(document.getElementById('<% = textfield3.ClientID %>').value=="")
{
document.getElementById('<% = textfield3.ClientID %>').value='e-mail:';
document.getElementById('<% = textfield3.ClientID %>').style.color="#cccccc";
}

</script>


is it working?? i used that so it must work! wat ur problem?

Gomathi Nayagam

Please Rate my answer if it has helpful to you



Author: Miss Meetu Choudhary    15 Oct 2008Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

use InnerHTML or InnerText for that

==
Thanks and Regards
Meetu Choudhary

Thanks and Regards
Miss Meetu Choudhary (Site Coordinator)
Go Green Save Green
My Profile on Google



Author: gomathinayagam    16 Oct 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

the same code will working for textarea also!! use like here

<textarea id="textfield4" runat="server" class="textBox" name="textfield4" onblur="addtxt1();"
onfocus="cler1();" rows="4" style="width: 129px; color: #cccccc">Feedback:</textarea>

function cler1(){
if(document.getElementById('<% = textfield4.ClientID %>').value=='Feedback:')
{
document.getElementById('<% = textfield4.ClientID %>').value="";
document.getElementById('<% = textfield4.ClientID %>').style.color="#1c6b99";
}
}
function addtxt1(){
if(document.getElementById('<% = textfield4.ClientID %>').value=="")
{
document.getElementById('<% = textfield4.ClientID %>').value='Feedback:';
document.getElementById('<% = textfield4.ClientID %>').style.color="#cccccc";
}
}

Gomathi Nayagam

Please Rate my answer if it has helpful to you



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.


Next : dynamically filling textbox
Previous : Windows installer in web application
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use