Closed Thread
Results 1 to 2 of 2

Thread: Hide and seek with a textbox character

  1. #1
    dgates is offline Newbie
    Join Date
    Dec 2007
    Posts
    3
    Rep Power
    0

    Hide and seek with a textbox character

    Hello All - I already posted this in the javascript forum, but don't know if the issue is with javascript of C#... (if this if frowned upon please let me know) Anyway...

    I need to have a specific button pressed when a user finishes entering text and presses enter (while still focused on the textbox) in order to initiate a filter on a list.

    I am capturing keypresses and recognizing when enter is pressed, the problem is, the last character is striped from the textbox before the behind code does the search *UNLESS* I run in debug mode and set a breakpoint in the javascript function - if I do that it works perfectly.

    I am using Visual Studio 2005, the behind code is in C# and I am using javascript to capture key presses...

    (in the .aspx file)

    Code:
    <radI:RadTextBox ID="unitRadTextBox" runat="server" LabelCssClass="radLabelCss_Default" Skin="Office2007" Width="125px"></radI:RadTextBox>
    Code:
    <asp:Button runat="server" ID="findButton" BorderWidth="1px" BackColor="Silver" Text="Find" BorderStyle="Ridge" CausesValidation="False" OnClick="findButton_Click" OnClientClick="enableShowAllButton()"></asp:Button>

    (in the C# file)

    Code:
    protected void Page_Load(object sender, EventArgs e){
        ...
        unitRadTextBox.Attributes.Add("onKeyPress", "catchEnterKey('" + findButton.ClientID + "', this, '" + unitRadTextBox.ClientID + "', event, '"+ Application +"')");
    }

    (in the javascript file)

    Code:
    // the following points the enter key to the correct button to click.
    function catchEnterKey(findButton, textbox, findTextbox, mozEvent, application){
         var key;
         key = window.event.keyCode;
         if (key == 13){
            //Get the button the user wants to have clicked
            var btn = document.getElementById(findButton);
            btn.click();
            event.keyCode = 0;
        }
    }
    Note: I also have this in my javascript file:

    Code:
    // the following catches all key presses and stops backspace from causing the browser to go to the previous page
    document.onkeydown = keyCatcher;
    function keyCatcher() {
        var e = event.srcElement.tagName;
    
        if (event.keyCode == 8 && e != "INPUT" && e != "TEXTAREA") {
            event.cancelBubble = true;
            event.returnValue = false;
        }
    }
    Any insight is much appreciated!

    Dave.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    dgates is offline Newbie
    Join Date
    Dec 2007
    Posts
    3
    Rep Power
    0
    Additional information:

    If I put the breakpoint before "if (key == 13){" in catchEnterKey it works, but if it is placed within the if statement it does not...

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 7
    Last Post: 10-12-2011, 06:24 AM
  2. How to seek a folder I have made in drive "C"
    By dpgodage in forum Visual Basic Programming
    Replies: 4
    Last Post: 10-13-2010, 02:23 AM
  3. I have a problem fixing the error " No space left on device : Illegal seek
    By Uni616 in forum Linux Programming and Scripting
    Replies: 1
    Last Post: 09-20-2010, 04:36 PM
  4. Hide and seek with a textbox character
    By dgates in forum JavaScript and CSS
    Replies: 0
    Last Post: 12-06-2007, 01:50 PM

Tags for this Thread

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