Invalid postback or callback argument ASP.NET

I got this error

I got this error because I was using a ready made html5 template. The problem was duplicate form tag used multiple times in the template. Removing that get rid of the error.

To be exact my duplicate form tag was in the master page which was a bit hard to find.

AP.NET misplaced tags can give you big headache

ill formed tag
I was trying to add a new tab to the existing 2 tabs. I copied some 250 lines of code of the second tab, changed all IDS and ControlIDs for validation etc and finally made the code work. But only to find out that my tab3 would not appear, even though its heading did. I spend some time over this and tried to figure out what I am missing. After all I did not work with ASP.NET TABS before.

Eventually found out that the contents of TAB3 were not showing because they were embedded one level below. I tried to find out what could be the cause but the panel itself seemed fine and were placed adjacent to each other. Then I set out on validating every control inside the TAB, from top to the bottom, starting with panel, tables and gridviews. Found out one anomaly where the code was like this

See that </tr> and </table> are interrupted by </panel>. It should have been like this

It took me 2 days to find out this was the cause of the problem. Now my TAB3 is working fine and I can work on real code rather than why TAB3 is not working :)

It is an error to use a section registered as allowDefinition=’MachineToApplication’ beyond application level

Scott Michell wrote an excellent article about the above error explaining exactly why are you getting this error. Basically you are opening the parent folder of a project in Visual Studio and you get this error. Since web.config in this case is in sub folder, you get this error.

A little Explanation

There can be more than one web.conf files in your application. They can be all in root or in sub folders as in nested form. The root web.conf can contain almost all elements but that that are nested in sub folders may not contain certain elements. This error is about this scenario.


Lets say you have project in this folder


If you open myfirstapp in Visual Studio you will get the above error. To resolve reopen the project and select main as your project.

Accessing Local Resources in MVC

You want to localized your resource or in other words put them in a resource file in the local folder, how do you access it in MVC?

Local resource demo


Here is how you will access it

    public class Student
      // Constuctor
        public Student()
            Name = MyStrings.name1;

        public string Name { get; set; }

A better way of doing it to put all resources in inside a separate folder and give them proper extension depending on where they will be used. For Example I can use

The program will automatically pick the right resource depending on the culture setting of the computer. In this case you will have to include using statement to point to the resource file.

using LocalResource.Models.LocalizedStrings;

Must declare the scalar variable “@ID”


In an ASP.NET Application, you are using ListView, you are trying to delete a record. Update, Insert everything works fine but delete does not work. The SQL syntax is correct

You are using Eval or Bind with your parameter like this

Your ListView is declared like this

Error Message:

The error is coming from SQL not ASP.NET
Must declare the scalar variable “@ID”.

You will find that although the error is coming from SQL but the cause is ASP.NET ListView.

Why is this error?

First of all it is interesting to knote that this error is not comming from ASP.NET or C# code. This is comming from SQL. you can verify this by reading the actual exception. It will say SQL Exception. The problem here is that someone the @ID is not properly updated and blinded into the delete query, that causes this exception.


Solution in this case is really simple. Include DataKeyNames=”ID” parameter in your ListView declaration. That should address the problem. It is funny at the end of the day, the error seems to be in ASP.NET not SQL while we know the exception is certainly from SQL.

Also note that you do not need to bind the ID field in your ASP.NET Code or even use Eval(“ID”). ID must simply exist in the select query. There is not need to display it in the ListView to make it work.

If it still does not solve your problem please let me know.