How to clear defaulttext in textbox by clicking on it and bring back defaut text in textbox when clicking outside of same textbox.

I'd suggest some client side JavaScript. Incorporate the onfocus and onblur events.

Please give me code or some eg, i am new to asp.net

On this forum, you'll find that you need to put a little effort in trying before getting help. Since I already had a code snippet, I'm providing it here for you. However, I would suggest that you do some research on your own. The following is a very simple example on how to use the onfocus and onblur events. by no means is this a final solution for your problem. It is only meant to be used as a demonstration. If you are new to asp.net, I would suggest that you go back and first learn HTML, CSS, and JavaScript really well before you continue with your asp.net development. It is going to make it easier for you as you get deeper into asp.net development.

<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
</head>
<script>
    function checkFocus(textValue) {
        if (textValue === "username") {
            document.getElementById("usernameenter").value = "";
        }
        else {
            document.getElementById("passwordenter").value = "";
        }
    }

    function doBlur(textValue) {
        if (document.getElementById("usernameenter").value === "") {
            document.getElementById("usernameenter").value = "username";
        }
        if (document.getElementById("passwordenter").value === "") {
            document.getElementById("passwordenter").value = "password";
        }
    }
</script>
<body>
Username: <input type="text"  name="username" value="username" onfocus="checkFocus(this.value)" onblur="doBlur(this.value)" /><br />
Password: <input type="password" name="password" value="Password" onfocus="checkFocus(this.value)" onblur="doBlur(this.value)" /><br />
</body>
</html>

Thank you friends...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.