can anyone tel me why the dropdownlist does not execute on textchanged ?

<%@ Page Language="VB" AutoEventWireup="true" CodeFile="index.aspx.vb" Inherits="Index" %>

<%@ Register TagPrefix="Ridwan" TagName="TabControl" Src="~/Assignment/Controls/TabControl.ascx" %> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>JJ Shop | Home</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
<script type="text/javascript" src="js/cufon-yui.js"></script>
<script type="text/javascript" src="js/arial.js"></script>
<script type="text/javascript" src="js/cuf_run.js"></script>

    <link rel="icon" href="images/icon_logo.png" />


<link rel="stylesheet" type="text/css" href="css/coin-slider.css" />
<script type="text/javascript" src="js/cufon-yui.js"></script>
<script type="text/javascript" src="js/cufon-aller.js"></script>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
<script type="text/javascript" src="js/coin-slider.min.js"></script>


    <script language="javascript" type="text/javascript">
        function clearText(field) 
        {
            if (field.defaultValue == field.value) field.value = '';
            else if (field.value == '') field.value = field.defaultValue;
        }
    </script>

    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            width: 243px;
        }
        .style3
        {
            width: 216px;
        }
    </style>

</head>
<body>

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

<div class="main">
  <div class="main_resize">

    <div class="header">
      <div class="logo">
        <h1><a href="#"><span>JJ</span> - Shop</a></h1>
      </div>
    </div>


   <div class="content">



      <div class="content_bg" runat="server">



            <div class="menu_nav">

              <ul>
                <li class="active"><a href="index.aspx">Home</a></li>
                <li><a href="products.aspx">Products</a></li>
                <li><a href="search.aspx">Search</a></li>
                <li><a href="contact.aspx">Contact Us</a></li>
                <li><a href="Admin/Admin_Prod_List.aspx">Admin</a></li>
              </ul>

            </div>


            <div class="slider">

                <div id="coin-slider"> 
                    <a href="#"><img src="images/slide1.jpg" width="400" height="307" alt="" /> </a> <a href="#"><img src="images/slide2.jpg" width="400" height="307" alt="" /> </a> <a href="#"><img src="images/slide3.jpg" width="935" height="307" alt="" /> </a> 
                </div>

            </div>

            <hr class="line" />

        <div class="mainbar" runat="server">

           <div class="wrapper" runat="server">

                <div class="box2" runat="server">
                    <h4>Popular Products</h4>

                          <div class="block poll-block" runat="server">


                                <h3> Select a category : 
                                  <asp:DropDownList ID="DropDownList1" autopostback="true" runat="server">

                                    <asp:ListItem Text="Lumber"  value="~/Assignment/Controls/FeatureProducts/ProductPage1.ascx" />
                                    <asp:ListItem Text="Cutting Tools" value="~/Assignment/Controls/FeatureProducts/ProductPage2.ascx" />
                                    <asp:ListItem Text="Roofing Materials" value="~/Assignment/Controls/FeatureProducts/ProductPage3.ascx" />
                                    <asp:ListItem Text="Fencing" value="~/Assignment/Controls/FeatureProducts/ProductPage4.ascx" />

                                  </asp:DropDownList>



                             </h3>
                              <hr class="line" />


                            <asp:PlaceHolder ID="PlaceHolder1" runat="server" />

                            <ridwan:products1 ID="Products1" runat="server" />

                            <ridwan:TabControl
            ID="TabStrip1"
            Runat="server"
            />

                          </div>

                </div>

            </div>

        </div>

        <div class="sidebar">

            <div class="box">

                <h4>Search</h4>

                    <div class="block poll-block">

                        <p class="field">
                        Product Name : 
                        <asp:Textbox id="txtsearch" Text="Search by product name" Cssclass="text" onfocus="clearText(this)" onblur="clearText(this)" runat="server" />
                        </p>
                        <table class="style1">
                            <tr>
                                <td class="style3">

                        <asp:Label ID="lblvalidation" runat="server" ForeColor="red" />

                                </td>
                                <td>

                        <asp:Button  id="btnSearch" runat="server" Text="Search" Cssclass="searchbox" />


                                </td>
                            </tr>
                        </table>

                    </div>

            </div>


                    <div class="box">
                          <h4>Member Section</h4>
                            <div class="block poll-block">

                                Username: <input type="text" id="Text1" name="username" class="text" />
                                <div class="cleaner_h10"></div>
                                <br/>
                                Password: <input type="password" id="password1" name="password" class="text" />
                                <div class="cleaner_h10"></div>
                                <br/>
                                <input type="submit" name="submit" id="submit1" value="Login" class="submit" />
                                &nbsp;&nbsp; No Account Yet? &nbsp;&nbsp; <a href="register.aspx">Register</a> 

                            </div>
                    </div>

                    <ridwan:adverts ID="Advert1" runat="server" />

        </div>

        <div class="clr"></div> <br/>



      </div>



      </div>


   </div>

</div>


    <div class="footer_resize">
        <center>  
            &copy; 2012. Designed by  <a href="mailto:ridwan_elnino@hotmail.com"> Moosuddee Mohammad Ridwan</a>   | All Rights Reserved.
        </center>
        <div class="clr"></div>
      </div>

  </form>

</body>
</html>

code behind :

Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged

    If DropDownList1.SelectedItem.Text = "Lumber" Then

        Products1.visible = False
        Dim featuredProductPath As String = DropDownList1.SelectedValue
        Dim featuredProduct As Control = Page.LoadControl(featuredProductPath)
        PlaceHolder1.Controls.Clear()
        PlaceHolder1.Controls.Add(featuredProduct)

    ElseIf DropDownList1.SelectedItem.Text = "Cutting Tools" Then

        Products1.Visible = False
        Dim featuredProductPath As String = DropDownList1.SelectedValue
        Dim featuredProduct As Control = Page.LoadControl(featuredProductPath)
        PlaceHolder1.Controls.Clear()
        PlaceHolder1.Controls.Add(featuredProduct)

    ElseIf DropDownList1.SelectedItem.Text = "Roofing Materials" Then

        Products1.Visible = False
        Dim featuredProductPath As String = DropDownList1.SelectedValue
        Dim featuredProduct As Control = Page.LoadControl(featuredProductPath)
        PlaceHolder1.Controls.Clear()
        PlaceHolder1.Controls.Add(featuredProduct)

    ElseIf DropDownList1.SelectedItem.Text = "Fencing" Then

        Products1.Visible = False
        Dim featuredProductPath As String = DropDownList1.SelectedValue
        Dim featuredProduct As Control = Page.LoadControl(featuredProductPath)
        PlaceHolder1.Controls.Add(featuredProduct)

    End If

End Sub
Member Avatar for LastMitch

can anyone tel me why the dropdownlist does not execute on textchanged ?

You can try this:

<asp:DropDownList ID="DropDownList1" autopostback="true" runat="server">
<asp:ListItem Text="Lumber" value="~/ProductPage1.ascx" />
<asp:ListItem Text="Cutting Tools" value="~/ProductPage2.ascx" />
<asp:ListItem Text="Roofing Materials" value="~/ProductPage3.ascx" />
<asp:ListItem Text="Fencing" value="~/ProductPage4.ascx" />
</asp:DropDownList>

---

if(DropDownList1.SelectedItem.Text=="Lumber"){
Products1.visible = False
Dim featuredProductPath As String = DropDownList1.SelectedValue
Dim featuredProduct As Control = Page.LoadControl(featuredProductPath)
PlaceHolder1.Controls.Clear()
PlaceHolder1.Controls.Add(featuredProduct)
txtsmst.text="Lumber";
return;
}
ElseIf(DropDownList1.SelectedItem.Text=="Cutting Tools"){
Products1.Visible = False
Dim featuredProductPath As String = DropDownList1.SelectedValue
Dim featuredProduct As Control = Page.LoadControl(featuredProductPath)
PlaceHolder1.Controls.Clear()
PlaceHolder1.Controls.Add(featuredProduct)
txtsmst.text="Cutting Tools";
return;
}
ElseIf(DropDownList1.SelectedItem.Text=="Roofing Materials"){
Products1.Visible = False
Dim featuredProductPath As String = DropDownList1.SelectedValue
Dim featuredProduct As Control = Page.LoadControl(featuredProductPath)
PlaceHolder1.Controls.Clear()
PlaceHolder1.Controls.Add(featuredProduct)
txtsmst.text="Roofing Materials";
return;
}
ElseIf(DropDownList1.SelectedItem.Text=="Fencing"){
Products1.Visible = False
Dim featuredProductPath As String = DropDownList1.SelectedValue
Dim featuredProduct As Control = Page.LoadControl(featuredProductPath)
PlaceHolder1.Controls.Add(featuredProduct)
txtsmst.text="Fencing";
return;
}
End If
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.