Default submit button

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

  1. #1

    Default Default submit button

    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....



    Matt Howeson Guest

  2. Similar Questions and Discussions

    1. Submit button
      I have a web form with a few text fields some validataion and a submit button. When I click the submit bittin the serverside event does not...
    2. [PHP] using submit button and PHP-HELP
      thanx for your help, Ive got flu and all these small things seem to be escaping my eyes. I just want to ask you a small question: If i want this...
    3. using submit button and PHP-HELP
      Hi, I have a form that has a submit button in it, when the button is pressed I want it to reload the same page, with the same URL, however when I...
    4. value submit button
      You can get the button value use code below: <?php echo $_POST;?> <form method="post"> <input type="submit" name="submit" value="submit1">...
    5. Help with Submit button...
      Hi, I have a graphic, I wanted to use it for a submit button. For some reason it does not work.. it acts more of a link. The problem with...
  3. #2

    Default Re: Default submit button

    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:
    [url]www.aboutfortunate.com[/url]

    "Out of chaos comes order."
    Nietzche


    "Matt Howeson" <howeson@hotmail.com> wrote in message
    news:iMjRa.49884$xd5.2763033@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....
    >
    >
    >

    S. Justin Gengo 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