Deploy ASP .NET MVC application using LocalDB to local IIS

When ASP application is published to IIS using LocalDB accessing the database may result in the following error:

An easy solution to fix this error is to set IIS Application pool Process Model Identity to Local System.

Do not forget also to copy the database to appropriate directory on the same host where IIS is running and to set corresponding path in project Build -> Publish -> Settings -> ApplicationDBContext (DefaultConnection). Use “…” browse button to easy set all database connection properties.

iis application pool process model Identity

C# Custom control – TextBox accepting only numbers, decimal numbers, signed numbers

The creation of custom control using Visual Studio involves the following steps:
1) Start Visual Studio;
2) Create new “Windows Control Library” project;
3) In the created project delete “User Control” file;
4) Go to “Project” > “Add User Control” and give it a name;
5) Change the inherited class to this that you want your control to be;
6) Create you custom properties for the control;
7) Compile the project: Go to “Build” > “Build Solution”;
8) The generated DLL file is located in you projects folder under:
“bin/Debug/UserContolName.dll” or “bin/Release/UserContolName.dll”.
That depends on how your solution is configured: “Debug mode” or “Release mode”.

Once created the DLL file can be added as custom control to Visual Studio toolbox.

This example shows how to create custom text box control which accepts only numbers, decimal separator or negative sign.
By default the text box only accepts numbers: 0123456789, to be entered.
There are two properties that allows the user to enter only numbers with decimal separator or signed numbers.
If both properties are enabled then the text box accepts numbers, decimal separator and negative sign.
A tool tip is shown with information what the user can enter in the text box, if incorrect data is tried to be entered.
A placeholder (watermark) functionality is added using the paint event of the text box.

Continue reading “C# Custom control – TextBox accepting only numbers, decimal numbers, signed numbers”

Visual Studio – Add custom control DLL to toolbox

To add a custom control to VisualStudio project:
1) Go to “Toolbox” tab;
2) Right click on it and click “Choose Items…”;


3) In the “Choose Toolbox Items” window click on the “Browse…” button.
Navigate to the location where your Dynamic Link Library (DLL) file is.
Click “OK”. Now your custom control is included into the Visual Studio toolbox.


For example of how to create custom control with C# and Visual Studio read this article:
C# Custom control – TextBox accepting only numbers, decimal numbers, signed numbers.