Link to home
Create AccountLog in
Avatar of bobstery

asked on

AutoPostBack not working with Master page for SelectedIndexChanged

I have several web pages that use a master page (see code below).  The problem that I am having is the fact that when my pages use the master page the AutoPostBack isnt working e.g. I have a drop down list with which I have activated the SelectedIndexChanged event, which populates a gridView.  This doesnt work when I use the master page but does when I dont.

Does auto postback work with Master Pages or is there something I need to do in order to get it working with them?

******* MASTER PAGE *********
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="test.master.cs" Inherits="test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" >
    <title>Test - Master Page</title>
    <link rel="stylesheet" type="text/css" href="styles.css" />
    <div id="container">
        <div id="header">
            <asp:contentplaceholder id="mainBody" runat="server" />        
            <div id="footer">
********* Example of Page using MASTER PAGE ****************
<%@ Page Language="C#" MasterPageFile="~/test.master" AutoEventWireup="true" CodeFile="testSizes.aspx.cs" Inherits="testSizes" EnableEventValidation="true" %>
<form id="form1" runat="server">
<asp:Content ID="Content1" ContentPlaceHolderID="mainBody" runat="Server">       
<asp:DropDownList ID="testItemDDL" runat="server" DataSourceID="testItemsDS"
                                    DataTextField="clti_name" DataValueField="clti_id" OnDataBound="testItemDDL_DataBound" AutoPostBack="True" OnSelectedIndexChanged="testItemDDL_SelectedIndexChanged">

Open in new window

Avatar of CB_Thirumalai
Flag of India image

Refer these links

I see   ---  <form id="form1" runat="server"> --- in content page.  I think this is not allowed.  Remove this and try.
I also see that you do not have a form tag in the master page.  You need to have a <form tag in the master page.
Avatar of bobstery


I have tried placing the form tag in the master page and the content page both do not work.  It only works if I don't use a master page for some reason.
May be you have something different in the master and content pages.  I have tried and was able to handle the post back and make the selected index changed event fire.  I am not sure how you have it in your forms.
Could you post the master page and content page code here so I can have a look and analyse the difference?
Avatar of CB_Thirumalai
Flag of India image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Forgot to mention the difference.  The only difference is, the dropdown you have is bound to a DataSourceID, whereas I have dummy data in it using ListItems.