Click here to Skip to main content
15,883,922 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a ASP.NET Web Form Project, in the master page I have a button(searchButton), I wrote a code in searchButton_Click event, after clicking on "Go" button (also if user types something in the textbox and press Enter key), user will be redirected to another page(FrmSearchResult.aspx)

C#
    public partial class Site1 : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void searchButton_Click(object sender, EventArgs e)
        {
            Session["nameA"] = searchText.Text;
            Response.Redirect("FrmSearchResult.aspx");
            Session.RemoveAll();
        }
    }
}


I also have Default.aspx page which has mentioned master page!
In the default page I have a textbox (searchUniTextBox), and I implemented a code in searchUniTextBox_ValueChanged event!
C#
protected void searchUniTextBox_ValueChanged(object sender, EventArgs e)
       {
           string searchUni = searchUniTextBox.Text.ToLower();
           string[] uniItem = new string[CheckBoxList1.Items.Count];
           for (int i = 0; i < CheckBoxList1.Items.Count; i++)
           {
               if (CheckBoxList1.Items[i].Text.ToLower().Contains(searchUni))
                   CheckBoxList1.Items[i].Selected = true;
           }
       }

But the problem is that whenever user presses Enter key, this event (searchUniTextBox_ValueChanged) executes, and immediately after that searchButton_Click in the master page executes!!!!!
I do not how I can prevent executing searchButton_Click event in the master page, when searchUniTextBox_ValueChanged event fires??
Thank you so much
Posted
Updated 5-Aug-14 13:37pm
v2

1 solution

In the button properties set
XML
UseSubmitBehaviour="false"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900