Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Cannot make master page button click default button

Avatar of mugsey
mugseyFlag for United Kingdom of Great Britain and Northern Ireland asked on
.NET ProgrammingASP.NETVisual Basic.NET
4 Comments1 Solution886 ViewsLast Modified:
I cannot get a search button to fire using the enter key as oppose to clicking the button on a master page.

Here I have the button set as default in the master page form

<form id="form1" runat="server" defaultbutton="_searchButton">

Then in the master page here is the button and search textbox

  <div id="search">
                    <div class='searchbox'>
                            <asp:TextBox ID="_searchTextBox" runat="server" CssClass="input2" AutoPostBack="true">Search for activity</asp:TextBox>
                        <asp:ImageButton ID="_searchButton" runat="server" CssClass="submit" ImageUrl="images/search_btn.gif"
                            OnClick="_searchButton_Click" AltText="Search"  />

In the code behind master page I set the default button on page load

this.form1.DefaultButton = _searchButton.UniqueID;

Then in each page load

In each page on page load I attempt to set the default button

        HtmlForm mainform = (HtmlForm)Master.FindControl("form1");
        mainform.DefaultButton = mainform.FindControl("_searchButton").UniqueID;  

However the search button is not being fireed


Avatar of DT20Three
DT20ThreeFlag of United Kingdom of Great Britain and Northern Ireland image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answers