We're building a brand new version of the site, and we'd love to hear your ideas
Members
Technology Zones
IBM Learning Center
Articles
Hosted By
Info
|
CLEAR A TEXTBOX on SETFOCUS IN ASP.NET with C#?
Last post 03-27-2008 10:30 AM by karan_21584. 14 replies.
-
03-20-2008 6:20 AM
|
|
Advertisement
|
|
-
-
Serval


- Joined on 08-21-2006

- Points 295
|
Re: CLEAR A TEXTBOX on SETFOCUS IN ASP.NET with C#?
you don't want to use javascript ?
serval
|
|
-
-
-
Serval


- Joined on 08-21-2006

- Points 295
|
Re: CLEAR A TEXTBOX on SETFOCUS IN ASP.NET with C#?
can you check this little code please ?
<html xmlns="http://www.w3.org/1999/xhtml" >
< head>
<title>Untitled Page</title>
<style type="text/css">#Text1 {
width: 290px;font-style: italic;
}
</style>
<script type="text/javascript">function textClearAndNormal()
{ document.getElementById("Text1").value="";document.getElementById("Text1").style.fontStyle= "normal";
}
</script>
</ head>
< body>
<form id="frm" name = "frm" action = ""><input id="Text1" type="text" value = "i am cool" onclick="textClearAndNormal()"/>
</ form></body>
</ html>
|
|
-
-
karan_21584


- Joined on 02-05-2007

- Points 1,460
|
Re: CLEAR A TEXTBOX on SETFOCUS IN ASP.NET with C#?
THANKS YAAR! can u help for this ? "
currently i m using ASP.NET with C# (.net 2005, 2.0 framework)
i have placed a calendar in my webform (calendar from toolbox --> calendar)
when i press the ESC key, the calendar should get INVISIBLE... how to do this?
help me. - KARAN
"
|
|
-
-
Serval


- Joined on 08-21-2006

- Points 295
|
Re: CLEAR A TEXTBOX on SETFOCUS IN ASP.NET with C#?
hi again ...
try this
<html>
< head><title></title>
</ head><body onkeypress = "show_key(event.which)">
< form runat ="server"><asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
</ form><script type="text/javascript">function show_key ( the_key )
{ if ( ! the_key )
{
the_key = event.keyCode;
}
// esc key is number 27 if(the_key == 27) {document.getElementById("Calendar1").style.visibility="hidden";
}
} </script>
</ body>
</ html>
|
|
-
-
-
karan_21584


- Joined on 02-05-2007

- Points 1,460
|
Re: CLEAR A TEXTBOX on SETFOCUS IN ASP.NET with C#?
Hi,
Your code helps me a lot. But i have one contraint while trying the same with multiple option, that is if i try to disable more than one calendar while press ESC, its getting object required error.
Thanks in advance,,,,
|
|
-
-
Serval


- Joined on 08-21-2006

- Points 295
|
Re: CLEAR A TEXTBOX on SETFOCUS IN ASP.NET with C#?
hi,
if you have more than one calendar , like calerdar1, calendar2, calendar3, and you want to make them all hidden on one action on esc key, you must write modify the previous code like this :
if(the_key == 27) {
document.getElementById("Calendar1").style.visibility="hidden";
document.getElementById("Calendar2").style.visibility="hidden";
document.getElementById("Calendar3").style.visibility="hidden";
bye
|
|
-
-
-
-
Serval


- Joined on 08-21-2006

- Points 295
|
Re: CLEAR A TEXTBOX on SETFOCUS IN ASP.NET with C#?
hi karan.
if the other calendars are "hidden" ; they can't be more hidden when you press esc, so if you leave my last code, i think it will work .
maheshkrp : at work , my boss don't like ajax embeddings for our applications .. because they are made for thousands and thousands users ... So for internal apps, we can use ajax or other stuff, for external apps, only classicak use of client javascript allowed.
|
|
-
-
-
karan_21584


- Joined on 02-05-2007

- Points 1,460
|
Re: CLEAR A TEXTBOX on SETFOCUS IN ASP.NET with C#?
thanks serval, i got the exact code.... just refer...
<script language="javascript" type="text/javascript"> function show_key ( the_key ) { if ( ! the_key ) { the_key = event.keyCode; } if(the_key == 27) { if(document.getElementById("Calendar1")) document.getElementById("Calendar1").style.visibility="hidden"; if(document.getElementById("Calendar2")) document.getElementById("Calendar2").style.visibility="hidden"; if(document.getElementById("Calendar3")) document.getElementById("Calendar3").style.visibility="hidden"; if(document.getElementById("Calendar4")) document.getElementById("Calendar4").style.visibility="hidden"; if(document.getElementById("Calendar5"))
} } </script>
<body onkeypress="show_key(event.which)">
|
|
-
Page 1 of 1 (15 items)
|
Search
Code Samples
New Members
|