Click here to Skip to main content
15,893,337 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a most annoying issue on my hands. I have the following code:

HTML
<asp:UpdatePanel ID="upDetails" runat="server" ChildrenAsTriggers="true" UpdateMode="Always">
                <ContentTemplate>
                    <div class="main">
<asp:DropDownList id="myDDL" AutoPostBack="True" OnSelectedIndexChanged="myDDL_SelectedIndexChanged" runat="server />
</div>
</ContentTemplate>
</asp:UpdatePanel>


I have a break point in my code on the relevant event, but it never gets hit. PLease help if possible.

Thanks in advance,
-Dom
Posted
Comments
[no name] 16-Apr-12 8:04am    
Have you checked for any other errors, perhaps JavaScript on the page, that may be preventing operation?
DominicZA 16-Apr-12 8:48am    
I just checked now and see that I am getting the following error: "Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation."

Any idea how to solve this?
[no name] 16-Apr-12 8:53am    
Any idea how to solve this? Yes. RTFM.

1 solution

check my example, works fine...

ASP.NET
<asp:scriptmanager id="ScriptManager1" runat="server" xmlns:asp="#unknown">
    </asp:scriptmanager>
    
    <asp:updatepanel id="UpdatePanel1" runat="server" xmlns:asp="#unknown">
        <contenttemplate>
            <asp:dropdownlist id="DropDownList1" runat="server" autopostback="true">
            </asp:dropdownlist>
            <br />            
            <asp:literal id="Literal1" runat="server"></asp:literal>
        </contenttemplate>        
    </asp:updatepanel>


C#
code behind:

protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        //subscribe events
        this.Load += new EventHandler(_Default_Load);
        DropDownList1.SelectedIndexChanged += new EventHandler(DropDownList1_SelectedIndexChanged);        
    }

    void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Literal1.Text = "selected item: " + DropDownList1.SelectedItem;
    }

    void _Default_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {
            //initilizind drop down list
            List<string> list = new List<string>() { "item 1", "item 2", "item 3" };
            DropDownList1.DataSource = list;
            DropDownList1.DataBind();
        }
    }</string></string>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900