You’ve just entered a new stored procedure and you run your web page which uses it and WHAM! – you get this error message. Luckily, it’s not too bad.
In .Net, sometimes, you must work with a querystring with many parameters and then, based on that, you must assign values to labels, textboxes or the like. Fortunately, it’s not that hard. Here, I’ll break it down into three parts – grabbing the entire querystring and then getting the individual parameters, followed by assigning them […]
Let’s say you’re on a computer with which you need a website on a server to have information about. First, you want the computer name you’re on. In my case, I ran the page on the website from a remote computer and I needed a textbox to default to the computer name where I was. […]
Let’s say you’re getting data from a database, and some of the data is null (maybe it’s an integer). A very common approach is to iterate through a table: dtEmployees = emp.Get(sqlGetEmployees); foreach (DataRow drEmp in dtEmployees.Rows) … ptt.Fieldname = drEmp[“Fieldname”] != DBNull.Value ? int.Parse(drEmp[“Fieldname”].ToString()) :0; That will populate the page with a ‘0’ for […]
If you are in a company in which the Fiscal Year does not start January 1st, it might become necessary in your code, to figure out what the actual Fiscal Year is at any point during the year. The following is a method (in C#) which returns a string based on the fact that the […]
I wanted to change the .Net Framework of my C# Windows app. Every site I went to to find out where to change said to right click on the project to get the properties page. Then, I would be able to change it in the ‘Target Framework’ dropdown. I never could see that dropdown.
Have you ever had a script tag in your code like this?: <script type=”text/javascript” src=”@Url.Content(“~/Scripts/myJavascriptLibrary.js”)” /> What’s more, did you find that it was not actually loading when the page ran?
This problem has been around since Classic ASP and is still there, in ASP.Net, when using an Access Database. The problem shows up when trying to update the database, but there is an easy fix.
Everyone using MVC generally knows about the ‘Required’ attribute for properties in the model. It’s surrounded by square brackets and placed just above the property. However, what if you want to change the displayed message to more user-friendly text? Well, it turns out that it’s very easy.
For those of us who came from a VB background, we know how great the immediate if is (iif). To do this in C#, it’s not so straightforward it seems, at least at first, but it’s just as easy and useful. Here’s how it’s the framework is done in C#: yourBool ? “true” : “false”; […]
All Things DotNet Discussed – Winforms/ASP.Net/SharePoint/WPF