ASP.NET page with base class with dynamic master page not firing events

Posted by Kangkan on Stack Overflow See other posts from Stack Overflow or by Kangkan
Published on 2010-05-03T17:13:19Z Indexed on 2010/05/03 17:18 UTC
Read the original article Hit count: 270

Filed under:

Hi guys! I am feeling that I have terribly wrong somewhere. I was working on a small asp.net app. I have some dynamic themes in the \theme folder and have implemented a page base class to load the master page on the fly. The master is having the ContentPlaceHolder like:

<asp:ContentPlaceHolder ID="cphBody" runat="server" />

Now I am adding pages that are derived from my base class and added the form elements. I know, Visual Studio has problem showing the page in the design mode. I have a dropdown box and wish to add the event of onselectedindexchange. But it is not working. the page is like this:

<%@ Page Language="C#" AutoEventWireup="true" Inherits="trigon.web.Pages.MIS.JobStatus" Title="Job Status"  AspCompat="true" CodeBehind="JobStatus.aspx.cs" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphBody" runat="Server">
  <div id="divError" runat="server" />
  <asp:DropDownList runat="server" id="jobType" onselectedindexchange="On_jobTypeSelection_Change"></asp:DropDownList>
</asp:Content>

I have also tried adding the event on the code behind like:

protected void Page_Load(object sender, EventArgs e)
{
    jobType.SelectedIndexChanged += new System.EventHandler(this.On_jobTypeSelection_Change);

    if (!IsPostBack)
    {
        JobStatus_DA da = new JobStatus_DA();
        jobType.DataSource = da.getJobTypes();
        jobType.DataBind();
    }
}

protected void On_jobTypeSelection_Change(Object sender, EventArgs e)
{

    //do something here
}

Can anybody help?

Regards,

© Stack Overflow or respective owner

Related posts about ASP.NET