Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

CLEAR A TEXTBOX on SETFOCUS IN ASP.NET with C#?

Last post 03-27-2008 10:30 AM by karan_21584. 14 replies.
Page 1 of 1 (15 items)
Sort Posts: Previous Next
  • 03-20-2008 6:20 AM

    CLEAR A TEXTBOX on SETFOCUS IN ASP.NET with C#?

    currently i m using ASP.NET with C# (.net 2003,1.1 framework).
    when i click on a textbox, the default TEXT is to be get cleared.... how to achieve it? - KARAN
    • Post Points: 15
  • Advertisement

    • Red Gate Software

    Advertisement

    Want to boost your .NET application performance?

    Some developers always seem to write efficient and lightening-fast code. What is their secret? It’s ANTS Profiler. “We improved the performance of the application up to 10 times” Dan Ports, Intrigma.

    Try it for yourself now.

  • 03-20-2008 9:24 AM In reply to

    • Serval
    • Top 500 Contributor
    • Joined on 08-21-2006
    • Member
    • Points 295

    Re: CLEAR A TEXTBOX on SETFOCUS IN ASP.NET with C#?

    you don't want to use javascript ?

    serval

    • Post Points: 10
  • 03-20-2008 10:17 AM In reply to

    Re: CLEAR A TEXTBOX on SETFOCUS IN ASP.NET with C#?

    its ok.. no problem....... but the thing is i need it as a search box.. (i.e... the text box content should be of "Enter the search criteria here..." and this should be italic style. when user click the textbox the content should get clear and normal texts should be typed (i seen this in many sites including MICROSOFT))

    • Post Points: 10
  • 03-20-2008 11:05 AM In reply to

    • Serval
    • Top 500 Contributor
    • Joined on 08-21-2006
    • Member
    • 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>

    • Post Points: 10
  • 03-20-2008 11:17 AM In reply to

    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

    "

    • Post Points: 10
  • 03-20-2008 1:02 PM In reply to

    • Serval
    • Top 500 Contributor
    • Joined on 08-21-2006
    • Member
    • 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>

    • Post Points: 10
  • 03-21-2008 5:30 AM In reply to

    Re: CLEAR A TEXTBOX on SETFOCUS IN ASP.NET with C#?

    THANKS A LOT MY DEAR!.. i m searching this for long time.. since i thought that we cant handle the SERVER SIDE process (.net calendar) in client side scripting (javascript).. i m not strong in JAVASCRIPT Sad

    And let me know how to HIDE/DISABLE the close button of Internet explorer using ASP.NET with C#?

    • Post Points: 5
  • 03-24-2008 5:21 AM In reply to

    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,,,,

     

      

    • Post Points: 10
  • 03-25-2008 10:28 AM In reply to

    • Serval
    • Top 500 Contributor
    • Joined on 08-21-2006
    • Member
    • 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

    • Post Points: 10
  • 03-25-2008 1:43 PM In reply to

    Re: CLEAR A TEXTBOX on SETFOCUS IN ASP.NET with C#?

    thanks  friend.but the thing is user may select anyone of the calendar. when user press ESC key, the problem arise... (all the 3 calendar will wont be visible all times. anyone only. User may select any calendar by clicking a button, select value and press ESC key).

    • Post Points: 5
  • 03-27-2008 5:49 AM In reply to

    • maheshkrp
    • Not Ranked
    • Joined on 02-12-2008
    • India
    • Junior Member
    • Points 240

    Re: CLEAR A TEXTBOX on SETFOCUS IN ASP.NET with C#?

    hi this is murthy, why don't you go for AJAX WaterMarkExtender,it is so simple ,when ever u click on text box it shows you a white space or else it shows you a water ever text you had given
    • Post Points: 15
  • 03-27-2008 8:29 AM In reply to

    • Serval
    • Top 500 Contributor
    • Joined on 08-21-2006
    • Member
    • 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.

    • Post Points: 5
  • 03-27-2008 10:25 AM In reply to

    Re: CLEAR A TEXTBOX on SETFOCUS IN ASP.NET with C#?

    thanks murthy, but i dt know to use AJAX. and i am more interested to implement in my project. can i know where i can find the ajax tutorials (FOR BEGINEERS?)

    • Post Points: 5
  • 03-27-2008 10:29 AM In reply to

    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)">

     

    • Post Points: 5
  • 03-27-2008 10:30 AM In reply to

    Re: CLEAR A TEXTBOX on SETFOCUS IN ASP.NET with C#?

     can anyone help me to my post "CSS OVERLAPPING MENU?? (URGENT!) " ? plz refer and reply
    • Post Points: 5
Page 1 of 1 (15 items)