Author Archive

ELMAH For Multiple Environments

Written by rsolberg. Posted in All, Technology

Web applications today, especially in medium to larger sized enterprises will be deployed in multiple environments. This allows the development teams to deploy the web application to an environment to verify changes made and that the application functions as expected before shipping it to production. So when you go to use plugins out there such as ELMAH, how should you go about this?  Out of the box, ELMAH allows you to set a single connection string name within your web.config as shown below. So what do you do when you actually have 3 different connection strings for all the environments that your web application exists in?  As it turns out, this is pretty easy to do because ELMAH is open source.  When you download the ELMAH code, you can include it inside your Visual Studio Solution or create a new solution specifically for ELMAH that you can reference from your web application.
If you’re reading this I’m guessing you don’t need help on how to go about doing that.  If you have specific questions, use the contact me page or the comments below.
With the ELMAH code open, look for the SqlErrorLog.cs file and add the code below.  This essentially allows you to set  the connection string property via your application to handle variations… So suppose this was a real world situation where you have a few different connection strings to manage like this: From your Global.asax.cs you can add a line of code to use the correct ELMAH database…
If you’re looking for more information on this, please contact me and I’d be glad to help.

ASP.Net GridView Context Menu

Written by rsolberg. Posted in All, Technology

This post will cover how to add a context menu to a GridView in ASP.Net utilizing jQuery. Once your site is setup to utilize jQuery, you can simply include a new style sheet and script file and get awesome functionality fairly easy! Take a look at this site here to download the required files and their code samples. Mine below shows how I used this on a GridView in ASP.NET…



jQuery Initialization

ASP.Net MVC MarkItUp Rich Text Editor

Written by rsolberg. Posted in All, Technology

MarkItUp identifies itself as being the Universal Markup Editor and from as far as I can tell, this is probably true! It was very easy to integrate the jQuery editor into my new Blog Admin views. I will try to illustrate how I was able to do this below. In addition to the jQuery MarkItUp files, you will also need to download the MarkUp to HTML parser/enhancer of your choice. I used the MarkdownSharp framework which is what the makes of have recently converted to an Open Source project.

Download the MarkItUp Files and MarkDown Sharp

You’ll need to take a look at the MarkItUp Website and download a couple of different files. – markItUp! pack 1.1.6 – Basic MarkDown Set – MarkDownSharp

Include MarkItUp Folder In Your Project

Now that you have the files downloaded, you need to deploy them to your MVC site. I have deployed the MarkItUp folder to my Scripts directory. The MarkItUp folder contains 3 different folders (sets, skins, and templates) and you’ll find a couple of .js files in the root of the folder. Once the MarkItUp folder is in your project, open up the MarkDown file that you downloaded above. You will need to deploy this folder into the Sets folder described above in your project.

LINQ to SQL Where Clause Optional Criteria

Written by rsolberg. Posted in All, Technology

Often times you may allow the users to query your system and you give them the choice of which fields to use in their query. This entry covers how to use optional where criteria within your query and avoid having to write 12 versions of the same query with different where clauses! Let’s take a real example of what I’m talking about… Suppose you have the following basic LINQ query.
  • Product Number – Comes from another table that can be joined to ItemsHeaders.
  • PO Number – a field within the ItemsHeaders table.
  • Order Number – Similar to PO #, just different column.
  • Product Status – Apply if the user selected this from a drop down.In order to accomplish this task, you need to create a couple of extension methods that allow you to apply a where filter if a condition is met.
    New Query!
    I must give special thanks to Andrew Robinson for assisting me with this code and functionality.
  • © Copyright RSolberg, 2003 - 2014. All Rights Reserved