multiple submit buttons -- controlling default button

T

thersitz

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) Also within that set of pages, I have a second, distinct seach box and
button that searches a specific database that is within an asp:content area
which inherits said masterpage

The problem is when using the enter key on the text box belonging to #2 --
it defaults to the submit button loaded into #1 and takes the user to the
wrong place.

Any way, I've googled and tried a number of things but no real success and
am hoping someone can point me to the cleanest, best approach to using 2
separate textbox/button instances, designed to search different data stores.
Below are some things I have tried. Thanks for any help.

I tried placing this in the content page code behind:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Page.Form.DefaultFocus = CISOBOX1.ClientID
Page.Form.DefaultButton = Button1.UniqueID
End Sub

This basically reversed the problem. When the page loads, the #2 submit
becomes the default button and using the enter key in #1 jumps the user to
the wrong page.

I tried wrapping the asp:content search combo in a <asp:panel runat=server
defaultbutton=Button1> and then adding the userControl button as the
defaultbuttonin my <form ...> tag within my masterpage -- but then I get
this error:

The DefaultButton of 'form1' must be the ID of a control of type
IButtonControl.

I tried adding this javascript in the <head ></head>of my masterpage and
then add the approriate event handler to the respective text boxes -- but
nothing

<script language="javascript">
function KeyDownHandler(btn)
{
// process only the Enter key
if (event.keyCode == 13)
{
// cancel the default submit
event.returnValue=false;
event.cancel = true;
// submit the form by programmatically clicking the specified
button
btn.click();
}
}
</script>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Changing Default Submit Button 3
Default button of a page 6
Default submit button 2
Default submit button 1
default submit button 4
Default button per textbox 1
Default Button on web form 0
Default submit button 1

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top