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 3866
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: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |