Category Archives: VB.NET

How to fix : Ajax.BeginForm doing full postback instead of partial.

I realised that in my MVC5 project  in Visual Studio I could not get the Ajax.BeginForm to work properly. It will always do a full postback.


I was trying to complete a Video Rating Page, where there are buttons to rate a video and once the user presses one of the rating button, it should thank the user and display the new rating value. I wanted this to shown on the same page without reloading the page, So I considered using AJAX.BeginForm which will simply work fine.


In order to have this AJAX functionality you will have to download the AJAX from NUGET.


Step 1

Install the following two highlighted packages from NUGET. Click here to check how to load Packages from NUGET in Visual Studio




Step 2

Once you have installed the above two packages through NUGET then do the following.

Go to the _Layout file in your _shared  folder in the Views. ( Note that I am using VB.NET but the example will work for C# also.


_Layout in the Shared Folder
_Layout in the Shared Folder


Open the _Layout.vbhtml file and browse to the bottom.


You will see the following two lines.



Now add the following line after the above two lines.
<script src=”~/Scripts/jquery.unobtrusive-ajax.min.js”></script>


I made a mistake of adding this script at the top of my page and my AJAX calls refused to work.

Then I realised that the AJAX has to be loaded after loading the jquery. So I added it at the last.





Add the script at the exact position show.



Step 3

Run your application.

Your AJAX Calls should work fine.







Could not load file or assembly ‘Antlr3.Runtime’ Error in Visual Studio 2013 Express

While working on the Visual Studio 2013 Express, I was happily burning the midnight oil to produce a new application, the application was coming on nicely.

But When I started work next day, suddenly I started getting the following error message.

Could not load file or assembly 'Antlr3.Runtime' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))


After searching for long and trying different optionx the following solution did work for me and I was back in action. Hope you can benefit it from as well.

Step 1
Go to the file explorer and search for %Temp% (See the screen below)


Step 2
You would see lots of file in Temp folder. Delete them all.


Step 3

Run Visual Studio 2013 Express again and you would be able to work again on your project.

How to use Select Case function to evaluate different conditions in VB.NET

If you have to select one of the options from various possibilities then your best option is to use the case

In VB.NET you would used something like below.

Select [ Case ] testexpression
[ Case expressionlist
[ statements ] ]
[ Case Else
[ elsestatements ] ]
End Select

Here is more practical example:

Dim intMyNumber as Integer = 20
Select Case intMyNumber
Case 1
Debug.WriteLine("The value of my number is 1")

Case 2,3,4
Debug.WriteLine("The value of my number is between 2 and 4.")

Case 5 to 9
Debug.WriteLine("The value of my number is between 5 and 9")

Case Else
Debug.WriteLine("The value of my number is not in 1 to 9")

End Select