Professional Web Applications Themes

Selecting all text in a textbox? - ASP.NET General

I've got a server-side textbox that receives the focus when the page loads. It has the text "Refine your Search" in the textbox. Obviously the user needs to highlight the "Refine your Search" section to replace this with thier text. I've googled and found javascript (which doesn't seem to work with the server side control). Is there a way to do this with ASPNET?? TIA Harry...

  1. #1

    Default Selecting all text in a textbox?

    I've got a server-side textbox that receives the focus when the page loads.
    It has the text "Refine your Search" in the textbox. Obviously the user
    needs to highlight the "Refine your Search" section to replace this with
    thier text.

    I've googled and found javascript (which doesn't seem to work with the
    server side control).

    Is there a way to do this with ASPNET??

    TIA
    Harry


    Harry Simpson Guest

  2. #2

    Default Re: Selecting all text in a textbox?

    Hi,

    you should be able to use JScript with ASP.NET just fine, in fact you need
    JScript to do what you want. What was the problem with the Jscript in
    combination with ASP.NET?

    Best regards,

    Marc Höppner
    NeoGeo

    "Harry Simpson" <hssimpsonnospamphgt.net> wrote in message
    news:OvHWwrRVDHA.3232tk2msftngp13.phx.gbl...
    > I've got a server-side textbox that receives the focus when the page
    loads.
    > It has the text "Refine your Search" in the textbox. Obviously the user
    > needs to highlight the "Refine your Search" section to replace this with
    > thier text.
    >
    > I've googled and found javascript (which doesn't seem to work with the
    > server side control).
    >
    > Is there a way to do this with ASPNET??
    >
    > TIA
    > Harry
    >
    >

    Marc Hoeppner Guest

  3. #3

    Default Re: Selecting all text in a textbox?

    Thanks Marc,

    I got it working:

    Added this to the codebehind load of screen:
    txtSearchText.Attributes.Add("onfocus", "SetSelected();")

    Then add this to the html of the aspx page:

    function SetSelected()
    {
    doent.Form1.txtSearchText.select();
    }

    Thanks for the reply
    Harry

    "Marc Hoeppner" <marchoeppnerhotmail.com> wrote in message
    news:ey8Kd5RVDHA.2004TK2MSFTNGP11.phx.gbl...
    > Hi,
    >
    > you should be able to use JScript with ASP.NET just fine, in fact you need
    > JScript to do what you want. What was the problem with the Jscript in
    > combination with ASP.NET?
    >
    > Best regards,
    >
    > Marc Höppner
    > NeoGeo
    >
    > "Harry Simpson" <hssimpsonnospamphgt.net> wrote in message
    > news:OvHWwrRVDHA.3232tk2msftngp13.phx.gbl...
    > > I've got a server-side textbox that receives the focus when the page
    > loads.
    > > It has the text "Refine your Search" in the textbox. Obviously the user
    > > needs to highlight the "Refine your Search" section to replace this with
    > > thier text.
    > >
    > > I've googled and found javascript (which doesn't seem to work with the
    > > server side control).
    > >
    > > Is there a way to do this with ASPNET??
    > >
    > > TIA
    > > Harry
    > >
    > >
    >
    >

    Harry Simpson Guest

  4. #4

    Default Re: Selecting all text in a textbox?

    You got it :) - Control.Attributes is kind of hard to find if you don't
    already know about it...

    "Harry Simpson" <hssimpsonnospamphgt.net> wrote in message
    news:%23or69CSVDHA.1816TK2MSFTNGP09.phx.gbl...
    > Thanks Marc,
    >
    > I got it working:
    >
    > Added this to the codebehind load of screen:
    > txtSearchText.Attributes.Add("onfocus", "SetSelected();")
    >
    > Then add this to the html of the aspx page:
    >
    > function SetSelected()
    > {
    > doent.Form1.txtSearchText.select();
    > }
    >
    > Thanks for the reply
    > Harry
    >
    > "Marc Hoeppner" <marchoeppnerhotmail.com> wrote in message
    > news:ey8Kd5RVDHA.2004TK2MSFTNGP11.phx.gbl...
    > > Hi,
    > >
    > > you should be able to use JScript with ASP.NET just fine, in fact you
    need
    > > JScript to do what you want. What was the problem with the Jscript in
    > > combination with ASP.NET?
    > >
    > > Best regards,
    > >
    > > Marc Höppner
    > > NeoGeo
    > >
    > > "Harry Simpson" <hssimpsonnospamphgt.net> wrote in message
    > > news:OvHWwrRVDHA.3232tk2msftngp13.phx.gbl...
    > > > I've got a server-side textbox that receives the focus when the page
    > > loads.
    > > > It has the text "Refine your Search" in the textbox. Obviously the
    user
    > > > needs to highlight the "Refine your Search" section to replace this
    with
    > > > thier text.
    > > >
    > > > I've googled and found javascript (which doesn't seem to work with the
    > > > server side control).
    > > >
    > > > Is there a way to do this with ASPNET??
    > > >
    > > > TIA
    > > > Harry
    > > >
    > > >
    > >
    > >
    >
    >

    Marc Hoeppner Guest

  5. #5

    Post Re: Selecting all text in a textbox?

    this dont works for me, im using vb.net 2008, My TextBox has this name: TxtCantidad, on page load event i have this " TxtCantidad.Attributes.Add("onfocus", "SetSelected();") " , i put this java function (im using master pages with an updatepanel).

    <script type="text/jscript">
    function SetSelected()
    {
    doent.Form1.TxtCantidad.select();
    }

    </script>

    *** and with this too: <script type="text/javascript">
    *** and always get this error: Unable to get value of the property 'getElementById': object is null or undefined.

    ** and my text box is defined by this:
    <asp:TextBox ID="TxtCantidad" runat="server" Width="90px">0</asp:TextBox>

    if i try with something like this
    control = doent.form1.getElementById('TxtCantidad');
    control.select()
    or
    control=doent.getElementById('TxtCantidad');
    control.select()

    I get same error.

    So, whats is wrong with this code, and why i cant select text?

    Thx for helping me.
    Last edited by cesardgo; January 24th at 04:38 PM. Reason: add more details
    cesardgo is offline Junior Member
    Join Date
    Jan 2013
    Posts
    1

Similar Threads

  1. Problem with selecting text
    By Rick_Arnaud@adobeforums.com in forum Adobe Illustrator Windows
    Replies: 2
    Last Post: July 8th, 03:44 PM
  2. Selecting Text Frames
    By Gabriel_Ayala@adobeforums.com in forum Adobe Indesign Windows
    Replies: 5
    Last Post: May 27th, 08:22 PM
  3. Selecting text problems
    By K._Johnson@adobeforums.com in forum Adobe Acrobat Windows
    Replies: 3
    Last Post: May 10th, 08:36 PM
  4. Having trouble selecting text in Illustrator CS
    By Corey_Grant@adobeforums.com in forum Adobe Illustrator Windows
    Replies: 3
    Last Post: April 29th, 08:41 PM
  5. Highlighting, Underlining, Selecting Text
    By mcguirejw@adobeforums.com in forum Adobe Acrobat Windows
    Replies: 1
    Last Post: April 12th, 04:28 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139