RegisterHiddenField to Capture Enter Resetting Application

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default RegisterHiddenField to Capture Enter Resetting Application

    Hi - I wanted to capture the enter button on a form since I have a
    datagrid with the first column being a delete button and if someone hits
    enter it deletes the first record. I coded:

    private void Page_Load(object sender, System.EventArgs e)
    {
    Page.RegisterHiddenField("__EVENTTARGET","SomeButt onOnThePage");
    Matthew Wieder Guest

  2. Similar Questions and Discussions

    1. resetting content and application
      hi there, i have a fairly complex application with a multitude of sections and sub-sections in it. i'd very much like to be able to reset all the...
    2. Resetting the zero point
      Does anyone know if it is possible to reset the zero point in Acrobat documents? The zero point is set to the top left of the document but I need it...
    3. Video Capture application using Flash CommunicationServer
      Hi, I am new to Flash and have been provided this requirement from my client. The client wants to create an application that will capture video...
    4. Score keeps resetting!
      Hi All, I'm making a Rock, Paper, Scissors game, and I have many lingo scripts which I've written. The file is here:...
    5. Resetting Preferences
      I'm embarrassed to even ask as many times as it has been posted...But can someone please refresh my memory on how to reset preferences. I printed it...
  3. #2

    Default RE: RegisterHiddenField to Capture Enter Resetting Application

    Hello Matthew,

    If we have multiple buttons on a webform, the first one rendered in the browser will fire when you press the Enter button.

    In this scenario, you need to add attributes to textboxes in the Page_Load event to check which Button_click event to fire.

    txtText1.Attributes("OnKeypress") = "return KeyPressFunction('button1')"
    txtText2.Attributes("OnKeypress") = "return KeyPressFunction('button2')"

    Then add the following code in the .aspx page

    <script language="javascript">
    function KeyPressFunction(buttonName)
    {
    if (event.keyCode == 13)
    {
    if (buttonName == "button1")
    {
    Form1.button1.click();
    return false;
    }

    if (buttonName == "button2")
    {
    Form1.button2.click();
    return false;
    }
    }
    }
    </script>

    Summary: If you are typing in txtText1 and hit Enter, button1_click event will fire, If you are typing in txtText2 and hit Enter,
    button2_click event will fire...regardless of what other buttons are on the page.

    Thanks.

    Best regards,
    Yanhong Huang
    Microsoft Online Partner Support

    Get Secure! - [url]www.microsoft.com/security[/url]
    This posting is provided "AS IS" with no warranties, and confers no rights.

    --------------------
    !Message-ID: <3F17F142.3010900@SatoriGroupInc.com>
    !Date: Fri, 18 Jul 2003 09:08:18 -0400
    !From: Matthew Wieder <Development@SatoriGroupInc.com>
    !User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02
    !X-Accept-Language: en-us, en, he
    !MIME-Version: 1.0
    !Subject: RegisterHiddenField to Capture Enter Resetting Application
    !Content-Type: text/plain; charset=us-ascii; format=flowed
    !Content-Transfer-Encoding: 7bit
    !Newsgroups: microsoft.public.dotnet.framework.aspnet
    !NNTP-Posting-Host: 207.106.112.178
    !Lines: 1
    !Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
    !Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:160248
    !X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    !
    !Hi - I wanted to capture the enter button on a form since I have a
    !datagrid with the first column being a delete button and if someone hits
    !enter it deletes the first record. I coded:
    !
    !private void Page_Load(object sender, System.EventArgs e)
    !{
    ! Page.RegisterHiddenField("__EVENTTARGET","SomeButt onOnThePage");
    ! .
    ! .
    !
    !but now when I hit enter it goes back to the first web page in the
    !application! Does anyone know either what is causing this behaviour, or
    !how I can just "eat" the enter button so it doesn't do anything?
    !thanks!
    !
    !


    Yan-Hong Huang[MSFT] Guest

Posting Permissions

  • You may not post new threads
  • You may 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