-4
<div class="container">
    <div id="top" class="">
        <div class="row">
            <div class="col-md-4">
                <br />
                <div role="form" style="border: 1px solid; padding: 2%; border-radius: 10px; background-color: #C0C0C0;">
                    <div class="form-group" style="text-align: center;">
                        <h3><a href="#" onclick="EasySearch();">Easy Search</a> | <a href="#" onclick="SmartSearch();">Smart Search</a></h3>
                    </div>
                    <form>
                        <div class="form-group" id="EasySearch" style="display: none;">

                            <asp:dropdownlist id="VehicaleMake" runat="server" class="form-control">
                                            <asp:ListItem Value="0">Select Make</asp:ListItem>
                                            <asp:ListItem Value="1">Audi</asp:ListItem>
                                            <asp:ListItem Value="2">honda</asp:ListItem>
                                        </asp:dropdownlist>
                            <br />

                            <asp:dropdownlist id="VehicleModel" runat="server" class="form-control">
                                            <asp:ListItem Value="0">Select Model</asp:ListItem>
                                            <asp:ListItem Value="1">civic</asp:ListItem>
                                            <asp:ListItem Value="2">A4</asp:ListItem>
                                        </asp:dropdownlist>
                            <br />

                            <asp:dropdownlist id="FuelType" runat="server" class="form-control">
                                            <asp:ListItem Value="0">Select Fuel Type</asp:ListItem>
                                            <asp:ListItem Value="1">petrol</asp:ListItem>
                                            <asp:ListItem Value="2">diesel</asp:ListItem>
                                        </asp:dropdownlist>
                            <br />

                            <asp:dropdownlist id="NoOfSeats" runat="server" class="form-control">
                                            <asp:ListItem Value="0">Number Of Seats</asp:ListItem>
                                            <asp:ListItem Value="1">1</asp:ListItem>
                                            <asp:ListItem Value="2">4</asp:ListItem>
                                        </asp:dropdownlist>
                            <br />

                            <div class="row">
                                <div class="col-md-6">
                                    <asp:textbox id="MinPrice" runat="server" cssclass="form-control"></asp:textbox>
                                </div>
                                <div class="col-md-6">
                                    <asp:textbox id="MaxPrice" runat="server" cssclass="form-control"></asp:textbox>
                                </div>
                            </div>
                            <div class="centered-text" style="text-align: center; margin-top: 20px;">
                                <%--<asp:button id="btn_EasySearch" runat="server" class="btn btn-primary btn-lg" onclick="btn_EasySearch_Click" text="Search" />--%>
                                            <asp:button id="Button1" runat="server" cssclass="btn btn-lg btn-primary btn-block" text="Search" onclick="btn_EasySearch_Click" />
                            </div>
                        </div>

                    </form>
                    <form>
                        <div class="form-group" id="SmartSearch" style="display: none;">

                            <asp:dropdownlist id="MakeSS" runat="server" class="form-control">
                                            <asp:ListItem Value="0">Select Make</asp:ListItem>
                                            <asp:ListItem Value="1">Audi</asp:ListItem>
                                            <asp:ListItem Value="2">honda</asp:ListItem>
                                        </asp:dropdownlist>
                            <br />

                            <asp:dropdownlist id="FuelSS" runat="server" class="form-control">
                                            <asp:ListItem Value="0">Select Fuel Type</asp:ListItem>
                                            <asp:ListItem Value="1">petrol</asp:ListItem>
                                            <asp:ListItem Value="2">diesel</asp:ListItem>
                                        </asp:dropdownlist>
                            <br />

                            <asp:dropdownlist id="ColorSS" runat="server" class="form-control">
                                            <asp:ListItem Value="0">Select color</asp:ListItem>
                                            <asp:ListItem Value="1">white</asp:ListItem>
                                            <asp:ListItem Value="2">red</asp:ListItem>
                                        </asp:dropdownlist>
                            <br />

                            <asp:dropdownlist id="SeatsSS" runat="server" class="form-control">
                                            <asp:ListItem Value="0">Number Of Persons</asp:ListItem>
                                            <asp:ListItem Value="1">1</asp:ListItem>
                                            <asp:ListItem Value="2">4</asp:ListItem>
                                        </asp:dropdownlist>
                            <br />

                            <div class="row">
                                <div class="col-md-6">
                                    <asp:textbox id="Min" runat="server" cssclass="form-control"></asp:textbox>
                                </div>
                                <div class="col-md-6">
                                    <asp:textbox id="Max" runat="server" cssclass="form-control"></asp:textbox>
                                </div>
                            </div>
                            <div class="centered-text" style="text-align: center; margin-top: 20px;">
                                <%--<asp:button id="Button2" runat="server" class="btn btn-primary btn-lg" onclick="btn_EasySearch_Click" text="Search" />--%>
                                           <asp:button id="Button3" runat="server" cssclass="btn btn-lg btn-primary btn-block" text="Seach" onclick="Smartsearch_Click" />
                            </div>
                        </div>

                    </form>

                </div>
            </div>
        </div>
    </div>
</div>
public partial class _Default : Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

       // System.Windows.Forms.Button clickedButton = (System.Windows.Forms.Button)sender;
    }

    protected void btn_EasySearch_Click(object sender, EventArgs e)
    {
        System.Windows.Forms.Button clickedButton = sender as System.Windows.Forms.Button;
        string Make = VehicaleMake.SelectedItem.Text;
        string Model= VehicleModel.SelectedItem.Text;
        string Fuel= FuelType.SelectedItem.Text;
        string Seats= NoOfSeats.SelectedItem.Text;
        string Minprice= MinPrice.Text;
        string Maxprice= MaxPrice.Text;

        string EasySearchData = Make + "," + Model + "," + Fuel + "," + Seats + "," + Minprice + "," + Maxprice;
        //MessageBox.Show(EasySearchData);
        Response.Redirect("EasySearch.aspx?SearchDetail='" + EasySearchData + "'");
    }

    protected void Smartsearch_Click(object sender, EventArgs e)
    {
        string Make = MakeSS.SelectedItem.Text;
        string Fuel = FuelSS.SelectedItem.Text;
        string color = ColorSS.SelectedItem.Text;
        string Seats = SeatsSS.SelectedItem.Text;
        string Minprice = Min.Text;
        string Maxprice = Max.Text;

        string SmartSearchData = Make + "," + Fuel + "," + color + "," + Seats + "," + Minprice + "," + Maxprice;
        //MessageBox.Show(EasySearchData);
        Response.Redirect("SmartSearch.aspx?SearchDetail='" + SmartSearchData + "'");
    }
}

I have 2 forms in a container. When i click on Easy search, it give other form and on smart search it give another. Both have search button. But when I click on smart search's search button, it did not go to that function. But easy search is working.

This is smart search form which is not working

TZHX
  • 5,291
  • 15
  • 47
  • 56
ALi Raza Darr
  • 149
  • 1
  • 1
  • 9
  • Mistake is here : OnClick="btn_EasySearch_Click" you are using same events for two buttons. Change event name from code behind and aspx button – Mehmet Mar 17 '16 at 13:25
  • 1
    Instead of adding such long code, add only relevant lines/ lines which you are having problem with. No one will like to spend so much time to read so much of code – It's a trap Mar 17 '16 at 13:26
  • `"when I click on smart search's search button, it did not go to that function"` - What does that even mean? – David Mar 17 '16 at 13:27
  • @Mehmet if i do change method name, it wont go to that method. – ALi Raza Darr Mar 17 '16 at 14:09
  • @David i have put onClick="Smartsearch_Click" but it is not going to that function. Instead page reloads. – ALi Raza Darr Mar 17 '16 at 14:10
  • Please show you 'Smartsearch' onclick event in code behind. – sr28 Mar 17 '16 at 14:12
  • @ALiRazaDarr: `"i have put onClick="Smartsearch_Click""` - Not according to the code posted in the question you haven't. – David Mar 17 '16 at 14:16
  • @sr28 i've updated my question. These are the 2 functions which are running behind. btn_EasySearch_Click() is working properly but other one is not. It only reloads the page. – ALi Raza Darr Mar 17 '16 at 14:25
  • 1
    I've just noticed you've tagged this as asp.net webforms, but you're showing 2 forms on the same page. You can only have 1 form per page. What page is your code from? EasySearch.aspx? Is this actually winForms? – sr28 Mar 17 '16 at 14:43
  • Should only be one form, with runat=server in it http://stackoverflow.com/questions/7544454/can-we-use-multiple-forms-in-a-web-page – Nikki9696 Mar 17 '16 at 15:47
  • thankyou @Nikki9696 :) – ALi Raza Darr Mar 17 '16 at 17:52

1 Answers1

0

Near the bottom of your code is this line:

<asp:Button ID="Smartsearch" runat="server" CssClass="btn btn-lg btn-primary btn-block" Text="Seach" OnClick="btn_EasySearch_Click" />

This is your 'search' button, which should be doing your 'Smart Search', which currently sets the 'OnClick' event to "btn_EasySearch_Click". This should presumably be set to your SmartSearch click event e.g. "btn_SmartSearch_Click".

sr28
  • 4,728
  • 5
  • 36
  • 67
  • I have put that in my code, but still its not working. – ALi Raza Darr Mar 17 '16 at 14:20
  • Please show your 'btn_SmartSearch_Click' event code. – sr28 Mar 17 '16 at 14:21
  • I've updated my question with those 2 methods. Kindly see them. – ALi Raza Darr Mar 17 '16 at 14:31
  • @ALiRazaDarr - check that your Smart Search button is wired up to the Smartsearch_Click event. Right click the button, click 'Properties', click the lightning icon at the top of the properties menu and confirm that the SmartSearch_Click event is selected under the 'Click' event. – sr28 Mar 17 '16 at 14:31