dropDownList Problem

Discussion in 'ASP .Net Web Controls' started by nurit, Jan 27, 2005.

  1. nurit

    nurit Guest

    hi,
    I have a simple program with dropdownlist and textbox.
    Write any text in the textbox and change the dropdownlist.
    On dropdownlistchange i alert the results.
    The program works well on my computer but when i copy the project to
    the server it doesn't work. It doesn't go in the
    DropDownList1_SelectedIndexChanged at all!!!
    Like it doesn't exist!!! it goes to the 'Page Load' function and shows
    the textbox value and show nothing on the dropdownlist alert.
    please tell me what i did wrong ?????????

    thanks

    nurit

    WebForm2.aspx:
    <%@ Page language="c#" Codebehind="WebForm2.aspx.cs"
    AutoEventWireup="false" Inherits="test.WebForm2" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>WebForm2</title>
    <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" Content="C#">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema"
    content="http://schemas.microsoft.com/intellisense/ie5">
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <asp:DropDownList id="DropDownList1" autopostback="True"
    style="Z-INDEX: 101; LEFT: 208px; POSITION: absolute; TOP: 136px"
    runat="server"></asp:DropDownList>
    <asp:TextBox id="TextBox1" style="Z-INDEX: 102; LEFT: 176px;
    POSITION: absolute; TOP: 192px"
    runat="server"></asp:TextBox>
    </form>
    </body>
    </HTML>

    WebForm2.aspx.cs:
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;

    namespace test
    {
    /// <summary>
    /// Summary description for WebForm2.
    /// </summary>
    public class WebForm2 : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.TextBox TextBox1;
    protected System.Web.UI.WebControls.DropDownList DropDownList1;

    private void Page_Load(object sender, System.EventArgs e)
    {
    // Put user code to initialize the page here

    Response.Write ("<script>alert('Page_Load : " + TextBox1.Text +
    "');</script>");
    Response.Write ("<script>alert('Page_Load : " +
    DropDownList1.SelectedValue + "');</script>");
    if (!IsPostBack)
    {
    DropDownList1.Items.Add(new ListItem("select","1"));
    DropDownList1.Items.Add(new ListItem("item2","2"));
    DropDownList1.Items.Add(new ListItem("item3","3"));
    }

    }

    #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: This call is required by the ASP.NET Web Form Designer.
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
    this.DropDownList1.SelectedIndexChanged += new
    System.EventHandler(this.DropDownList1_SelectedIndexChanged);
    this.Load += new System.EventHandler(this.Page_Load);

    }
    #endregion

    private void DropDownList1_SelectedIndexChanged(object sender,
    System.EventArgs e)
    {
    Response.Write ("<script>alert('SelectedIndexChanged in: " +
    DropDownList1.SelectedValue + "');</script>");
    }

    }
    }
     
    nurit, Jan 27, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mr2_93
    Replies:
    1
    Views:
    3,625
    mr2_93
    Oct 2, 2005
  2. tshad
    Replies:
    8
    Views:
    2,246
    tshad
    Oct 19, 2005
  3. =?Utf-8?B?SnVhbmpv?=

    GridView: Filtr DropDownList from another DropDownList

    =?Utf-8?B?SnVhbmpv?=, Dec 23, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,885
    =?Utf-8?B?SnVhbmpv?=
    Dec 23, 2005
  4. =?Utf-8?B?SnVhbmpv?=

    GridView: Filter DropDownList for another DropDownList

    =?Utf-8?B?SnVhbmpv?=, Dec 29, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,316
    =?Utf-8?B?SnVhbmpv?=
    Dec 29, 2005
  5. keithb
    Replies:
    1
    Views:
    12,073
    shauns1
    Nov 1, 2006
Loading...

Share This Page