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