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