RE: Wrong Form Submit

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Cowboy (Gregory A. Beamer) - MVP (NoSpamMgbworld_at_comcast.netNoSpamM)
Date: 12/13/04


Date: Mon, 13 Dec 2004 08:15:04 -0800

This can get a bit tangled. You can set a default button for a certain page
state, but this, by itself, will not solve your issue, as you also require
the login to work in a similar manner (or that is my assumption).

One option (a bit kludgy) is to handle both buttons with the same event and
test the sender object passed in to determine how to handle.

You can also take control of the submission in client side JavaScript, but
that makes the app harder to maintain, as you circumvent the built in
abilities of ASP.NET.

I would venture the best solution is moving away from having the login on
the form and moving it to another page. This is more inline with the ASP.NET
methodology and allows you to force logon for certain pages rather easily.
You can go to a link instead when you do that.

I have created many "multiple form" forms (actually one form with specific
controls visible at any one time). Setting the default button is as easy as
adding a handler in your code behind (do not have a snippet readily available
right now, but I can post later). As mentioned, this is a non-solution for
you, as your form has two forms showing at once.

---
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
***************************
Think Outside the Box!
***************************
"P1ayboy" wrote:
> I have two forms on a page, one for logging in a user and a second one to 
> search thesite. The problem is, when i enter data into the search and hit 
> enter, it activates the login button. I need to know how to associate a 
> textbox with a particular button.
> 
> 
> <asp:TextBox ID="keyword" Runat=server ></asp:TextBox>
> <asp:imagebutton OnCommand="runSearch" id="runbutton" Runat=server />
> 
> so when the focus is on keyword and I hit enter, it will run "runSearch" and 
> not other command on other buttons.
> 
> Cheers
> 
> Rob


Relevant Pages

  • RE: Wrong Form Submit
    ... Bloody designers huh! ... > the login to work in a similar manner. ... > the form and moving it to another page. ... >> search thesite. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Microsoft Publisher 2007 Mozilla Problems
    ... When moving to other pages from the home page, users with firefox are seeing ... I'll remove the images from the master page and try again. ... I don't understand the last question about the ftp login when "moving" ...
    (microsoft.public.publisher.webdesign)
  • Re: Web login problem
    ... Your so-caled colution will work only if the user isnt some twitchy 14 yr old that can hit the button faster than the redirect can happen.. ... the Login page, this means that if they hit Back from the Login page ... When user logs out the cookie is disposed. ... Or specify the time in minutes before a cached page expires: ...
    (microsoft.public.dotnet.languages.vb)
  • Re: running an event when user presses ENTER from a txt box
    ... > We have a form with login and password text boxes. ... > have the system execute the same code as if they had hit the OK button. ... > Private Sub Password_KeyDown ...
    (microsoft.public.access.forms)
  • Intranet Design Question
    ... Management wants ... people to be required to login when they hit the website from either internal ...
    (microsoft.public.inetserver.iis.security)