Revised:Cascadingdropdown causes invalid postback or callback argument error

A while back I wrote a post about how to solve the error message you can get from using the Cascading Dropdown Extender from the Ajax Control Toolkit which is:

“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”

However, that post seems to be one of my more popular ones and I have gotten a lot of comments on requesting me to provide some sample code and maybe go more I depth on how to fix it.

So this post will go through a little sample project.
You can get the source code from my github repo.


The example is based on the example that is included in Ajax Control Toolkit download and I will not go into detail how the service methods have been implemented.

Referencing Ajax Control Toolkit

The first thing I will do after creating the new web application project is to add a reference to the Ajax Control Toolkit (the dll I have added from NuGet) and include that in the project.
Then add these two lines in your web.config:

(under assemblies)

            <add assembly="AjaxControlToolkit" />

(under pages/controls)

          <add tagPrefix="asp" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit"/>

This makes it possible to use the asp tag prefix in your markup to reference the Ajax Control Toolkit controls. It works like a link between the assembly and the namepace to a tag prefix of your choice.
You could add this as a page directive in your markup but then it has to be in each and every page in your project (DRY – don´t repeat yourself)

The Markup

Part of the markup looks like this:


For a detail about the markup and the code behind methods I refer to the sample project.

The Problem

When that renders it looks like this:


You see that the cascading dropdowns works as I expect (i.e. the values are populated in cascading order) but as soon as I click the save button:



The solution

I have already gone through the details of why this happens in my other post so this is just a summary on how to solve it.

First, create a class that inherits from DropDownList and nothing more:

namespace CascadingDropdownExtenderExample.WebControls
    public class NoValidationDropDownList : System.Web.UI.WebControls.DropDownList

This class is included inside my sample project and just has a sub namespace of WebControls. My project is not strong named so the assembly name is simply CascadingDropdownExtenderExample (if I had strong named it it would have a full 4-part name).

The next step then is to replace the regular DrowDownLists in the markup with this one. This can be done via a page directive or an entry to web.config

In a page directive (the tag prefix I have chosen is asp)

<%@ Register TagPrefix="asp" Namespace="CascadingDropdownExtenderExample.WebControls" Assembly="CascadingDropdownExtenderExample" %>

In web.config

		<add tagPrefix="asp" namespace="CascadingDropdownExtenderExample.WebControls" assembly="CascadingDropdownExtenderExample"/>

Note that these two are equivalent but the web.config one is more DRY.

So, after I have modified the markup it looks like this now:


And now the code works again…


I hope this makes thing clearer for you!


  1. #1 by autobazar on April 14, 2011 - 15:46

    Thanks – where is article source?

    • #2 by Johan Leino on April 15, 2011 - 07:59

      click the link where is says (download from here) which leads you to the code

      • #3 by Andy on April 21, 2011 - 14:40

        There’s no code there. Can you please fix the link or upload the code?

      • #4 by Johan Leino on April 21, 2011 - 14:48

        Sorry, forgot to make it public…should work now

  2. #5 by ? on June 28, 2011 - 23:04

    Could not load file or assembly ‘CascadingDropdownExtenderExample’ or one of its dependencies. The system cannot find the file specified.

  3. #6 by Shirin on August 31, 2011 - 15:16

    Johan, thank you for this great article. It gave me great hints. I made the class and called it CascadingDropdownExtender.cs —> public class CascadingDropdownExtender : System.Web.UI.WebControls.DropDownList . Also added it to the web.config in your example you used to populate your dropdowns and I used . In the form, instead of now I have . The dropdowns are populated with correct data and all works before submit. But I still get the same old “Invalid postback…” error that we all hate. I’ve miss any anything here? Should I do something else? Please advice. Thanks

    • #7 by Johan Leino on September 2, 2011 - 21:27

      can’t really say what’s wrong. can u please try to explain in more detail

  4. #8 by Shirin on August 31, 2011 - 15:30

    hummm… I noticed that the tags are removed from my comment above and it makes it nonsense.

  5. #9 by Shirin on September 6, 2011 - 13:14

    Basically I’ve done all you said in your post. I got the cascading dropdown working but at submit I’ve received the same old security error. Finally I decided to use the asp:UpdatePanel and update only the 4 dropdowns at postback. It’s working pretty good 🙂 I can post my code if you think it will be helpful to other developers.

  6. #11 by Matt on September 19, 2011 - 22:27

    Thanks a million

  7. #12 by alex on September 20, 2011 - 03:55

    Thanks!!! It work like a charm!!

  8. #13 by Lungile on October 12, 2011 - 16:00

    Thank you ever so much Johan, really appreciate this all the way from South Africa:-)

  9. #15 by Momin Ansari on July 13, 2012 - 11:31

    Thanks Johan Leino for the Code

  10. #16 by handitaokviyanto on October 14, 2012 - 08:52

    Please reupload the pictures.. I can not see the picture how does it looks like

  11. #18 by Josh on October 23, 2012 - 22:06

    Johan can you help me with this error?

    Parser Error Message: Could not load file or assembly ‘CascadingDropdownExtenderExample’ or one of its dependencies. The system cannot find the file specified.

    • #19 by Johan Leino on November 2, 2012 - 23:12

      well, it’s there “The system cannot find the file specified”. ASP.NET can’t find the assembly that contains the CascadingDropdownExtenderExample class you are trying to use. Is it in the BIN folder or…?? Don’t know how much more I can help you

  12. #20 by Dix on January 22, 2013 - 19:46

    Thanks Johan – in 12+ years of .net I never ran into anything like this before. You’re work through was brilliant and clean – mostly appreciate you taking the time to post this walk-through!

  13. #22 by Sushant on November 27, 2013 - 09:40

    Doesn’t work at all.

  14. #23 by HendiggityDoggyDog on February 1, 2014 - 06:53

    boom….thanks……this worked perfectly for me.

  15. #24 by Arno on December 30, 2015 - 13:31

    Hello Thanks a lot but I am having an issue to get it work. I am getting the error “Could not load file or assembly ‘CascadingDropdownExtenderExample’ or one of its dependencies. The system cannot find the file specified.”.
    I have created the NoValidationDropDownList.cs file and put it in the app_code folder, is there anything else I should do?

  16. #25 by Alex on April 12, 2016 - 21:32

    I think this solved my problem. Thanks for the article.

  1. CascadingDropDown casues invalid postback or callback argument error « Johan Leino
  2. Revised: CascadingDropDown casues invalid postback or callback argument error
  3. CascadingDropDown causes invalid postback or callback argument error « Johan Leino

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: