I am sure this question has been asked many times, however I am yet to find
a satisfactory solution to the problem. I have a number of user controls
within an asp.net page, a login box, a search box, and contact form. I wish
to be able to ensure that when the user presses enter in the appropriate
textbox control, the correct form is validated and submitted.
I have tried a number of methods to achieve this goal, the main one being
setting the __EVENTTARGET hidden form field value to the id of the button I
wish to be "clicked" when the enter key is pressed. I do this by adding an
onkeypress attribute to each of the textboxes within the usercontrol. This
doesn't appear to be working however, and one button is always "clicked"
rather than the others.
I wondered if anyone may have some advice on how to handle this approach
where there are several user controls which would each have been a form in
their own right in old style asp. Also I'd be interested in how people
would handle the validation of such a scenario, I am inclined to just write
my own validation routines for the scenario, rather than rely on the inbuilt
validation, which doesn't appear to work well for this.
I have also found it necessary to check each of the validators individually
within the user control to check if the data submitted IsValid, if I try to
call Page.IsValid then it will validate all of the validation controls
within the page, not just within the user control. Am I missing something
here or is there anyway to validate only the controls within the current
user control.
This would seem to be a fairly common situation, however I am finding it
very difficult to easily achieve the results I am looking for using ASP.Net.
Any thoughts appreciated.... 1 3909
Matt,
Here's how I'm taking care of it:
TextBox.Attribu tes.Add("onkeyd own", "javascript :if( (event.which &&
event.which == 13) || (event.keyCode && event.keyCode ==
13)){document.F orm1." & Button.ClientID & ".click();retur n false;}else
return true;")
--
S. Justin Gengo, MCP
Web Developer / Programmer
Free Code Library At: www.aboutfortunate.com
"Out of chaos comes order."
Nietzche
"Matt Howeson" <ho*****@hotmai l.com> wrote in message
news:iM******** *************@s tones.force9.ne t... I am sure this question has been asked many times, however I am yet to
find a satisfactory solution to the problem. I have a number of user controls within an asp.net page, a login box, a search box, and contact form. I
wish to be able to ensure that when the user presses enter in the appropriate textbox control, the correct form is validated and submitted.
I have tried a number of methods to achieve this goal, the main one being setting the __EVENTTARGET hidden form field value to the id of the button
I wish to be "clicked" when the enter key is pressed. I do this by adding
an onkeypress attribute to each of the textboxes within the usercontrol.
This doesn't appear to be working however, and one button is always "clicked" rather than the others.
I wondered if anyone may have some advice on how to handle this approach where there are several user controls which would each have been a form in their own right in old style asp. Also I'd be interested in how people would handle the validation of such a scenario, I am inclined to just
write my own validation routines for the scenario, rather than rely on the
inbuilt validation, which doesn't appear to work well for this.
I have also found it necessary to check each of the validators
individually within the user control to check if the data submitted IsValid, if I try
to call Page.IsValid then it will validate all of the validation controls within the page, not just within the user control. Am I missing something here or is there anyway to validate only the controls within the current user control.
This would seem to be a fairly common situation, however I am finding it very difficult to easily achieve the results I am looking for using
ASP.Net. Any thoughts appreciated.... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: spence |
last post by:
Hi All
How do I make it so that when a user clicks in a search text field, the
default entry (in this case "Search") is removed automatically - they
are then faced with a blank search box and can type straight away
Thanks in advance
|
by: Christopher Benson-Manica |
last post by:
According to http://www.w3schools.com/tags/tag_button.asp, the type
attribute of the <button> tag is optional. Is the UA at liberty to
choose any type it wishes if the attribute is omitted? Does the
presence or lack of a DTD impact the answer?
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
|
by: chris |
last post by:
i have a form with 3 buttons with a text box next to each button
what i want to do is when a textbox is filled out the default button is
changed to the button next to that text box rather than the first button on
the form.
how would i do this.
Chris
|
by: Bratislav Jevtic |
last post by:
hi,
how to make some push button default on the form? for instance, I've got 2
buttons (Submit, Cancel). submit is on the left, cancel on the right side.
on enter key pressed, cancel button is processed - wrong. so, how to make a
button default (when one presses ENTER then it's processed onClick event)?
thanks,
bj
|
by: RA |
last post by:
Hi
I have asp.net web app. When a user clicks the enter key when he is viewing
the aspx web form, it jumps to the starting web form. How can I handle the
user hitting the enter key and to redirect it to a default button. So lets
say that I have a button name - Submit - if the user clicks anywhere in the
form on the enter key I want it to default to a click on the 'Submit' button
which is an asp.net button.
| |
by: Sanjeeb Sarangi |
last post by:
I have got a couple of Serverside Button Controls in a page. Each button performs different actions, e.g. Button1 performs Submit, Button2 performs Cancel etc. Now, I want the default button mapped to the Enter key would be "Submit". I know a couple ways to achive this functionality using html buttons. But, how to achieve this functionality with Serverside buttons? Any idea
Thanks in advance
|
by: Jason |
last post by:
I know this is going to be a stupid question, but I'm in a crunch and don't
have time to research it as much as I'd like. How do you tell the web form
which button is the default button. So if a user fills out the form and
hits enter instead of clicking the submit button, the correct button gets
triggered.
In other words I have a web form with a cancel button and a submit button
and when I go into the form the and fill it out and hit...
|
by: Xarky |
last post by:
Hi,
I have a page with 2 textboxes(Name and Surname) and two
buttons(Submit and Reset).
Now I have set the tab for them
1 Name
2 Surname
3 Submit
4 Reset
|
by: AlecL |
last post by:
Hi All,
I have added a user control onto an aspx page and want to make the
submit button of that user control the default button when the panel
in which the user control is located is visible. I have used the
code:
Page.RegisterHiddenField("__EVENTTARGET", "Login.btnSubmit")
in the Page Load event but this does not make the submit button
default(enter) button. Any ideas on how can I do this. I have also
tried using just the name of...
|
by: thersitz |
last post by:
Hi,
Using aspnet3.5,VStudio 2008, VB
1.) I have a set of pages, with a search text box button within a
userControl that searches across our websites and is registered in a
masterpage.
2) Also within that set of pages, I have a second, distinct seach box and
button that searches a specific database that is within an asp:content area
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |