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 3872
Matt,
Here's how I'm taking care of it:
TextBox.Attributes.Add("onkeydown", "javascript :if((event.which &&
event.which == 13) || (event.keyCode && event.keyCode ==
13)){document.Form1." & Button.ClientID & ".click();return 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*****@hotmail.com> wrote in message
news:iM*********************@stones.force9.net... 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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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. ...
|
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)...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
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...
| |