selectedIndexChanged event not firing please help me

Last post 05-02-2008 12:11 AM by krishnav. 4 replies.

Sort Posts:

  • selectedIndexChanged event not firing please help me

    05-01-2008, 6:12 AM
    • Loading...
    • krishnav
    • Joined on 05-01-2008, 5:45 AM
    • Vijayawada
    • Posts 80

    I am using Ajax enabled pages but i did't use any control in this page. eventhough SelectedIndexChanged Event is not firing. I have added items from database there is no repetation and also set autopost back propety="true". i want to add items from database when select one item from above dropdownlist.

    it showing the fallowing javascript error: Object doesn't support this property or method 

    i am sending code for that..

     

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="rentals.aspx.cs" Inherits="_Default" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head runat="server">

    <title>AP-Adda::Everything for you</title>

    <link href="../Styles/style.css" rel="stylesheet" type="text/css" />

    </head>

    <body>

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

    <div id="wrapper">

    <div id="wrapper2">

    <div id="header">

    <div id="logo">

    <h1>

    APadda</h1>

    </div>

    <div id="menu">

    <ul>

    <li><a href="index.aspx">Home</a></li>

    <li><a href="e-zone.aspx">E-Zone</a></li>

    <li><a href="e-books.aspx">E-Books</a></li>

    <li><a href="rentals.aspx">Rentals</a></li>

    <li><a href="gallery.aspx">Gallery</a></li>

    <li><a href="contact.aspx">Contact</a></li>

    </ul>

    </div>

    </div>

    <div id="page">

    <div id="content">

    <div class="post">

    <h2 class="title">

    Searh for Rentals</h2>

    <div class="entry">

    Rental-Type

    <asp:DropDownList ID="drpsrentType" runat="server" AutoPostBack="True" OnSelectedIndexChanged="drpsrentType_SelectedIndexChanged1" />

    <br />

    <br />

    Range

    <asp:DropDownList ID="drprentRangefrom" runat="server" Style="margin-left: 33px;">

    <asp:ListItem>Select</asp:ListItem>

    </asp:DropDownList>

    &nbspTo&nbsp;&nbsp;&nbsp;&nbsp<asp:DropDownList ID="drprentRangeto" runat="server"

    Style="margin-left: 10px;">

    <asp:ListItem>Select</asp:ListItem>

    </asp:DropDownList><br />

    <br />

    City

    <asp:DropDownList ID="drpsCity" runat="server" Style="margin-left: 46px;" AutoPostBack="True" />

    <br />

    <br />

    Location

    <asp:DropDownList ID="drpsLocation" runat="server" Style="margin-left: 19px;">

    <asp:ListItem>Select</asp:ListItem>

    </asp:DropDownList><br />

    <br />

    <strong>Note:</strong><br />

    <br />

    House Rent for one Month.<br />

    Incase of Car, Bike and Function hall rent period is one day.<br />

    <br />

    <asp:Button ID="btnRental" runat="server" Text="Search" CssClass="button" OnClick="btnRental_Click" />

    </div>

    </div>

    <div class="post">

    <h2 class="title">

    Submit Rentals</h2>

    <div class="entry">

    <p>

    Name

    <asp:TextBox ID="TextBox1" runat="server" CssClass="control"></asp:TextBox><br />

    <br />

    Contact-No

    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />

    <br />

    Rent

    <asp:TextBox ID="TextBox3" runat="server" Style="margin-left: 37px;"></asp:TextBox><br />

    <br />

    Rental-Type

    <asp:DropDownList ID="drpRentalType" runat="server" Style="margin-left: -2px;" />

    <br />

    <br />

    City

    <asp:DropDownList ID="drpCity" runat="server" Style="margin-left: 43px;" AutoPostBack="True"

    OnSelectedIndexChanged="drpCity_SelectedIndexChanged">

    </asp:DropDownList><br />

    <br />

    Location

    <asp:DropDownList ID="drpLocation" runat="server" Style="margin-left: 16px">

    <asp:ListItem>Select</asp:ListItem>

    </asp:DropDownList></p>

    <br />

    <asp:Button ID="btnSubmit" Text="Submit" CssClass="button" runat="server" />

    </div>

    </div>

    </div>

    <!-- end #content -->

    <div id="sidebar">

    <ul>

    <li id="search">

    <h3>

    Search</h3>

    <form id="searchform" method="get" action="">

    <div>

    <input type="text" name="s" id="s" size="15" />

    <input name="submit" type="submit" value="Go" />

    </div>

    </form>

    </li>

    <li>

    <h3>

    Latest New's</h3>

    <p>

    <strong>APadda</strong> is going start a new website on Reddy community. It has

    been developing since last month. I am requseting you people to help through providing

    info about Popular Reddy's <a href="#">More&hellip;</a></p>

    </li>

    </ul>

    <h3>

    Real Estate</h3>

    </div>

    <!-- end #sidebar -->

    <div style="clear: both;">

    &nbsp;</div>

    <div id="widebar">

    <div id="colA">

    <h3>

    E-Books (To download Login)</h3>

    <dl class="list1">

    <dt>C#-Cook book</dt>

    <dd>

    <a href="#">William</a></dd>

    <dt>Asp.Net-vb</dt>

    <dd>

    <a href="#">Balaguruswami</a></dd>

    <dt>Java</dt>

    <dd>

    <a href="#">Jamesford</a></dd>

    <dt>CSS</dt>

    <dd>

    <a href="#">Krishna</a></dd>

    <dt>HTML-Tips</dt>

    <dd>

    <a href="#">Margarate</a></dd>

    </dl>

    </div>

    <div id="colB">

    <h3>

    Rent a House, Car or Bike</h3>

    <p>

    Apadda is providing&nbsp; valuble service to the visitos. Here you can search for

    a rent house, car, bike or function hall. As same you can submit your rent house,

    bike, car detials to the visitors. We are providing a efficient service to get or

    submit rentals.. <a href="#">More&hellip;</a></p>

    </div>

    <div id="colC">

    <h3>

    Visit Gallery Now</h3>

    <ul class="list2">

    <li><a href="#">

    <img src="../images/img12.jpg" alt="" width="50" height="50" /></a></li>

    <li><a href="#">

    <img src="../images/img13.jpg" alt="" width="50" height="50" /></a></li>

    <li><a href="#">

    <img src="../images/img14.jpg" alt="" width="50" height="50" /></a></li>

    <li><a href="#">

    <img src="../images/img15.jpg" alt="" width="50" height="50" /></a></li>

    <li><a href="#">

    <img src="../images/img16.jpg" alt="" width="50" height="50" /></a></li>

    <li class="nopad"><a href="#">

    <img src="../images/img17.jpg" alt="" width="50" height="50" /></a></li>

    </ul>

    </div>

    <div style="clear: both;">

    &nbsp;</div>

    </div>

    <!-- end #widebar -->

    </div>

    <!-- end #page -->

    </div>

    <!-- end #wrapper2 -->

    <div id="footer">

    <p>

    (c) 2007 Ap-Adda. Design by <a href="#">Sathya Websolutions</a></p>

    </div>

    </div>

    </form>

    </body>

    </html>

     

     

    using System;

    using System.Data;

    using System.Configuration;

    using System.Web;

    using System.Web.Security;

    using System.Web.UI;

    using System.Web.UI.WebControls;

    using System.Web.UI.WebControls.WebParts;

    using System.Web.UI.HtmlControls;

    using Common;

    using BusinessFacade;

    #endregion

    public partial class _Default : System.Web.UI.Page

    {

    #region "common variable declaration "

    Common.UserInfo uinfo = new UserInfo();

    BusinessFacade.BAUserInfo binfo = new BAUserInfo();

    #endregion

    #region
    "page load "protected void Page_Load(object sender, EventArgs e)

    {

    location();

    rentType();

    }

    #endregion

     

    #region "To add cities to the ddList "public void location()

    {

    DataTable objtable = null;

    objtable = binfo.BALocation(uinfo);

    string city="Select,";

    for (int i = 0; i < objtable.Rows.Count; i++)

    {

    city=city+objtable.Rows[i][
    "cityName"].ToString()+ ",";

    }

    if (city.Length > 0)

    {

    city = city.Substring(0, city.Length - 1);

    }

    city.TrimEnd(
    ',');string[] cities = city.Split(',');

    drpCity.DataSource = cities;

    drpCity.DataBind();

    drpsCity.DataSource = cities;

    drpsCity.DataBind();

    }

    #endregion

    #region
    "To add Rent type to ddList "public void rentType()

    {

    DataTable objtable = null;

    objtable = binfo.BArentType(uinfo);

    string rent = "Select,";

    for (int i = 0; i < objtable.Rows.Count; i++)

    {

    rent = rent + objtable.Rows[i][
    "rentType"].ToString() + ",";

    }

    if (rent.Length > 0)

    {

    rent = rent.Substring(0, rent.Length - 1);

    }

    rent.TrimEnd(
    ',');string[] renttype = rent.Split(',');

    drpRentalType.DataSource = renttype;

    drpRentalType.DataBind();

    drpsrentType.DataSource = renttype;

    drpsrentType.DataBind();

    }

    #endregion

    #region
    "To add Locations to ddList on select "public void Address()

    {

    DataTable objtable = null;

    uinfo.cityName = drpCity.SelectedItem.Value.ToString();

    objtable = binfo.BAAddress(uinfo);

    string address = "Select,";for (int i = 0; i < objtable.Rows.Count; i++)

    {

    address = address + objtable.Rows[i][
    "rentType"].ToString() + ",";

    }

    if (address.Length > 0)

    {

    address = address.Substring(0, address.Length - 1);

    }

    string[] addresses = address.Split(',');

    drpLocation.DataSource = addresses;

    drpLocation.DataBind();

    }

    #endregion

    #region
    "dropdown list to select location "protected void drpCity_SelectedIndexChanged(object sender, EventArgs e)

    {

    Address();

    }

    #endregion

    #region
    "To search for the rental "protected void btnRental_Click(object sender, EventArgs e)

    {

    }

    #endregion

    #region
    "To get the Rent Range to dropdownlist "protected void drpsrentType_SelectedIndexChanged1(object sender, EventArgs e)

    {

    DataTable objtable = null;

    uinfo.rentType = drpsrentType.SelectedItem.Value;

    objtable = binfo.BArentRange(uinfo);

    if (objtable.Rows.Count != null)

    {

    for (int index = 0; index < objtable.Rows.Count; index++)

    {

    drprentRangefrom.Items.Add(
    new ListItem(objtable.Rows[index]["rentRangeFrom"].ToString()));drprentRangeto.Items.Add(new ListItem(objtable.Rows[index]["rentRangeTo"].ToString()));

    }

    }

    }

    #endregion

    #region
    "To add location to the list in search "protected void drpsCity_SelectedIndexChanged(object sender, EventArgs e)

    {

    DataTable objtable = null;

    uinfo.cityName = drpsCity.SelectedItem.Value.ToString();

    objtable = binfo.BAAddress(uinfo);

    string address = "Select,";for (int i = 0; i < objtable.Rows.Count; i++)

    {

    address = address + objtable.Rows[i][
    "rentType"].ToString() + ",";

    }

    if (address.Length > 0)

    {

    address = address.Substring(0, address.Length - 1);

    }

    string[] addresses = address.Split(',');

    drpsLocation.DataSource = addresses;

    drpsLocation.DataBind();

    }

    #endregion

    }

  • Re: selectedIndexChanged event not firing please help me

    05-01-2008, 6:56 AM
    • Loading...
    • richiej
    • Joined on 09-25-2006, 10:24 AM
    • Posts 281

    Have you used breakpoints in the Page_Load method and your event to prove that the postback occurs and the event is NOT firing?

  • Re: selectedIndexChanged event not firing please help me

    05-01-2008, 5:55 PM
    • Loading...
    • sensiee
    • Joined on 04-30-2008, 4:57 PM
    • Posts 16

    just try the very first line:

    you seem to have a different codeFile from the inherited one.

    you have CodeFile="rentals.aspx.cs" in codeFile but your partial class is defined default. so, try having CodeFile="Default.aspx.cs"

    Hope that works

  • Re: selectedIndexChanged event not firing please help me

    05-01-2008, 8:30 PM
    • Loading...
    • BryianTan
    • Joined on 02-03-2008, 5:50 PM
    • VA
    • Posts 616

     hi, also make sure your javascript is enabled on your browser

    Bryian Tan
    MCP, MCAD
  • Re: selectedIndexChanged event not firing please help me

    05-02-2008, 12:11 AM
    • Loading...
    • krishnav
    • Joined on 05-01-2008, 5:45 AM
    • Vijayawada
    • Posts 80

    yes i have inserted break point. it is not postbacking when changed index.

Page 1 of 1 (5 items)
Microsoft Communities