Ask a Question related to ASP.NET General, Design and Development.
-
Matthew Wieder #1
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
-
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... -
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... -
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... -
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:... -
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... -
Yan-Hong Huang[MSFT] #2
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



Reply With Quote

