textbox text change

Last post 07-13-2009 12:47 PM by bond_003. 13 replies.

Sort Posts:

  • textbox text change

    02-13-2006, 7:29 AM
    • Member
      145 point Member
    • rupurt
    • Member since 12-21-2005, 6:48 PM
    • Posts 38
    i have been searching everywhere for a solution to my problem but havent been able to come up with one.

    i want to reduce the results of a list i print to a page as i type text into a textbox something based on the results printed. so i need to run a function each time the text changes. i tried to do this with OnTextChanged="true" and AutoPostBack="true" in the textbox but this only fires the event when i get out of the textbox.

    I have been trying to get to grips with the atlas beta and have used the AutoCompleteExtender but it wont work for my purposes because i need access to a radio list control which i cant pass into a WebService Function.
  • Re: textbox text change

    02-13-2006, 3:02 PM
    • Member
      117 point Member
    • jarrednicholls
    • Member since 02-13-2006, 7:47 PM
    • Baltimore, MD.
    • Posts 25

    You should handle the onkeypress client-side event of the textbox.  That should be all you need.  In that client-side event handler, get the current textbox.value and do an AJAX callback to your server-side method for results, then update your radio list according to what's returned.

    Hope that helps.

    Best regards,
    Jarred

  • Re: textbox text change

    02-15-2006, 8:40 AM
    • Member
      145 point Member
    • rupurt
    • Member since 12-21-2005, 6:48 PM
    • Posts 38
    how do i actually go about that? i find it very hard to understand the client side of atlas because there is no autocomplete or API
  • Re: textbox text change

    02-15-2006, 12:06 PM
    • Member
      117 point Member
    • jarrednicholls
    • Member since 02-13-2006, 7:47 PM
    • Baltimore, MD.
    • Posts 25

    Don't use the "Atlas API".  Just use standard JavaScript, and add a handler for onkeypress to the input, as such:

    <input type="text" id="myTextBox" onkeypress="myJavaScriptHandlerFunction();" />

    And you're done.  Inside that handler function, pass the textbox.value to an AJAX/Atlas callback function to get server results.

    Understand?

    Jarred

  • Re: textbox text change

    02-15-2006, 1:07 PM
    • Contributor
      7,416 point Contributor
    • Garbin
    • Member since 09-17-2004, 12:35 PM
    • Sassari, Italy
    • Posts 1,506
    • ASPInsiders
      TrustedFriends-MVPs

    Hi,

    are you using an auto-complete TextBox or a simple TextBox to do this? I don't understand if you want to update the list each time a character is typed into the TextBox or when an item is chosen from the completion list.

    Alessandro Gallo | Blog | My book: ASP.NET AJAX In Action
  • Re: textbox text change

    02-15-2006, 1:20 PM
    • Member
      117 point Member
    • jarrednicholls
    • Member since 02-13-2006, 7:47 PM
    • Baltimore, MD.
    • Posts 25

    I am confident he wants the former, w/ each character typed.  My solution is the way to accomplish this.

    Jarred

  • Re: textbox text change

    02-15-2006, 2:22 PM
    • Member
      145 point Member
    • rupurt
    • Member since 12-21-2005, 6:48 PM
    • Posts 38
    got it working!

    thanks for your help people. the onkeypressed is exactly what i needed
  • Re: textbox text change

    02-23-2006, 5:13 PM
    • Member
      121 point Member
    • leoguy
    • Member since 02-23-2006, 10:00 PM
    • Posts 50

    Jarred,

    I wanna call a server side method from a javascript funtion, would you pls help me that.

    When i call the following code from aspx file , i gets error TestSearch undefined whereas TestSearch.doSearch() is defined in codebehind, Make sure its not a webserivce call.

    I would really appreciate you.

    Note: I have script library and atlas.dll in the project.

    Thanks!

    <script type="text/javascript" >

    function callSearch() { this is called from a button.

    TestSearch.doSearch(OnComplete,OnTimeOut); 

    }

    function OnComplete(result) {

    alert(result);

    }

    function OnTimeOut() {

    alert("Timed Out");

    }

    </script>

     

  • Re: textbox text change

    02-24-2006, 1:43 PM
    • Member
      20 point Member
    • dleffel
    • Member since 02-24-2006, 11:37 AM
    • Posts 4
    I'm curious, is there a way to use the onKeyPress method where it wouldn't fire immediately, say wait 300 miliseconds to see if there are further changes. I don't want it to fire in the midst of typing a word, only when the user is done or has paused.

    I'm basically trying to accomplish what "onChange" accomplishes without having to leave the control.
  • Re: textbox text change

    02-25-2006, 5:40 AM
    • Contributor
      7,416 point Contributor
    • Garbin
    • Member since 09-17-2004, 12:35 PM
    • Sassari, Italy
    • Posts 1,506
    • ASPInsiders
      TrustedFriends-MVPs
    Hi,

    dleffel wrote:

    I'm curious, is there a way to use the onKeyPress method where it wouldn't fire immediately, say wait 300 miliseconds to see if there are further changes.

    nice suggestion. I've coded an Atlas behavior based on your requirement. You'll find the code here.
    Alessandro Gallo | Blog | My book: ASP.NET AJAX In Action
  • Re: textbox text change

    02-25-2006, 1:46 PM
    • Member
      20 point Member
    • dleffel
    • Member since 02-24-2006, 11:37 AM
    • Posts 4
    This is EXCELLENT. Thanks!
  • Re: textbox text change

    04-09-2006, 3:34 AM
    • Contributor
      2,857 point Contributor
    • Pluginbaby
    • Member since 11-20-2005, 8:07 PM
    • Canada
    • Posts 484
    • TrustedFriends-MVPs

    Really really nice one!!

    Thanks for the code, and the explanations with it !

    (If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

    Laurent Duveau
    Silverlight MVP / Silverlight Insider
    http://weblogs.asp.net/lduveau/
  • Re: textbox text change

    07-21-2006, 6:45 PM
    • Member
      5 point Member
    • erickvch
    • Member since 07-21-2006, 10:09 PM
    • Posts 1

    Hi! I got a similar problem.

    I need that an atlas update panel refreshes when the text value in a textbox Controls changes.

    I have a trigger that works fine when I type text in the textbox. So far so good.

    However, the textbox can also be filled by a javascript function that runs on a calendar popup. In this case no event is thrown and my panel isn't updated. So what can I do to handle that change on the text?

    Here is some of the code: 


    <asp:TextBox ID="TextBoxDate" runat="server" OnTextChanged="TextBoxDate_TextChanged" Width="155" AutoPostBack="true" >
    <atlas:UpdatePanel runat="server" ID="pnlSchedule" Mode="Conditional">
          <Triggers>
               <atlas:ControlValueTrigger ControlID="TextBoxDate" PropertyName="Text" />
                <atlas:ControlEventTrigger ControlID="TextBoxDate" EventName="TextChanged" />
          </Triggers>
          <ContentTemplate>
              <asp:Table ID="tabletoUpdate" runat="server">
              </asp:Table>
           </ContentTemplate>
    </atlas:UpdatePanel>

     
  • Re: textbox text change

    07-13-2009, 12:47 PM
    • Member
      2 point Member
    • bond_003
    • Member since 07-13-2009, 12:27 PM
    • Posts 1

     am new to ajax and havent done any sort of javascipting prior to this

    i TOO have been searching everywhere for a solution to my problem but havent been able to come up with one. i want to reduce the results of a list i print to a page as i type text into a textbox something based on the results printed.

    i need to run a function each time the text changes. i tried to do this with OnTextChanged="true" and AutoPostBack="true" in the textbox but this only fires the event when i get out of the textbox.

    these controls lie in a user control.

    i have this a script as in the user control page:

    function FilterDDL()
    {
            if (Trim(txtAreaCode.Text))  != ""
            {
            var lb as new listbox
            var s int
            s = 0
            for(s = 0 ; s < lstAreaCode.Items.Count-1 ; s=s+1)
                { if (InStr(lstAreaCode.Items(s).ToString, txtAreaCode.Text) = true)
                    {lb.Items.Add(ListBox1.Items(s)) ; }
                }
            lstAreaCode.Items.Clear();
            for(s = 0; s <lb.Items.Count - 1;s=s+1)
            { lstAreaCode.Items.Add(lb.Items(s).ToString); }
            lb.Dispose();
            }
    }

    i have installed ajax control toolkit and work on vs 2005.

Page 1 of 1 (14 items)