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 »

Insert Image to TextBox?


Posted Date: 19 Aug 2008      Posted By: Murugan      Member Level: Bronze     Points: 1   Responses: 4



Hi Friends

Its possible to set an Image to a Text Box .
Other How we want to do that.

Go through the below URL u Come to Know what i want.....

http://www.google.com/coop/cse?cx=007428522693030678892%3Asqmn7dng4ns

Google Search Img is present inside the Text Box When i click the Text Box its gone?
How i what to do like that.

Regards
Murugan K





Responses

Author: fayaz    19 Aug 2008Member Level: GoldRating: 4 out of 54 out of 54 out of 54 out of 5     Points: 6

Hi use on mouse over function for this

here is a sample code




<html>
<head>
<title>Change from Textbox to Password Field</title>
<script type="text/javascript">
function hidepass(){
document.login.ptext.style.display='none';
document.login.pass.style.display='';
document.login.pass.focus();
}

function showpass(){
document.login.pass.style.display='none';
document.login.ptext.style.display='';
document.login.ptext.focus();
}

function setEnd (el) {
if (el.createTextRange) {
var FieldRange = el.createTextRange();
FieldRange.moveStart('character', el.value.length);
FieldRange.collapse();
FieldRange.select();
}
}

</script>

<style type="text/css">
.black {font:10pt arial; color:#000000;}
.grey {font:10pt arial; color:#989898;}
</style>

</head>
<body>

<form name="login">
<input type="text" name="user" value="User Name" class="grey" size="15" onFocus="if(this.value==this.defaultValue) {this.value=''; this.className='black';}" onBlur="if(this.value=='') {this.value = this.defaultValue; this.className='grey';}"><br><br>

<input type="text" name="ptext" value="Your password" size="15" class="grey" onClick="hidepass(this);"><input type="password" name="pass" value="" size="15" class="black" style="display:none" onFocus="setEnd(this);" onBlur="if (this.value=='') {showpass(this);}">

</form>
</body>
</html>

Regards,
Faiz



Author: fayaz    19 Aug 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 4

to change image try this


<html>
...
<script type="text/Javascript">
function changeBgImage (image , id) {
element = getDocumentByID(id);
element.style.background-image = url(image);
}
</script>

<body>

<div id="test" onMouseOver="changeBgImage('images/bg2.gif','test')">
</div>

</body>
</html>

Regards,
Faiz



Author: Balthazor    20 Aug 2008Member Level: DiamondRating: 2 out of 52 out of 5     Points: 6

The above answer is correct(Fayaz' - Great Response) However
It requires a little change.

In above code while tabbing(Using tab instead click on textbox) through controls the original password textbox don't get focus and the password will be written in text control.

so Here is the changed code.

<html>
<head>
<title>Change from Textbox to Password Field</title>
<script type="text/javascript">
function hidepass(){
document.login.ptext.style.display='none';
document.login.pass.style.display='';
document.login.pass.focus();
}

function showpass(){
document.login.pass.style.display='none';
document.login.ptext.style.display='';
document.login.user.focus();
}

function setEnd (el) {
if (el.createTextRange) {
var FieldRange = el.createTextRange();
FieldRange.moveStart('character', el.value.length);
FieldRange.collapse();
FieldRange.select();
}
}

</script>

<style type="text/css">
.black {font:10pt arial; color:#000000;}
.grey {font:10pt arial; color:#989898;}
</style>

</head>
<body>

<form name="login">
<input type="text" name="user" value="User Name" class="grey" size="15" onFocus="if(this.value==this.defaultValue) {this.value=''; this.className='black';}" onBlur="if(this.value=='') {this.value = this.defaultValue; this.className='grey';}">
<br><br>
<input type="text" name="ptext" value="Your password" size="15" class="grey" onClick="hidepass(this);" onFocus="hidepass(this);">

<input type="password" name="pass" value="" size="15" class="black" style="display:none" onFocus="setEnd(this);" onBlur="if (this.value=='') {showpass(this);}">


</form>
</body>
</html>



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 : Accordian ..?
Previous : HOW CAN I FIT ASPX PAGE IN THE CONTENT PLACE HOLDER OF MASTER PAGE....URGENT
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use