You can easily create ASP.NET charts in Visual Studio 2010 and VS 2012. Here are the links for getting started.
VS 2010
Visual Studio 2010 Charts
VS 2012
Visual Studio 2012 Charts
A sample pie chart
Have fun!
Just some random development ramblings mostly related to the Microsoft .NET platform.
Friday, November 16, 2012
Friday, September 21, 2012
Randomly sort and display a set of elements using jQuery
I ran into a situation where I needed to randomly select a set of hidden elements from a web page and display only those elements. I also wanted to randomize the order of those elements so the page looked different each time. Here is a quick jQuery example.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var root = $('#tips');
var tips = $('div.singleTip:hidden');
$(tips).detach();
var count = 0;
var maxCount = 2;
while (count <= maxCount) {
var idx = Math.floor(Math.random() * tips.length);
if ($(tips[idx]).is(':hidden')) {
$(tips[idx]).show();
root.append($(tips[idx]));
++count;
}
}
});
</script>
<style type="text/css">
.singleTip {
display: none;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="tips">
<div class="singleTip">one</div>
<div class="singleTip">two</div>
<div class="singleTip">three</div>
<div class="singleTip">four</div>
<div class="singleTip">five</div>
<div class="singleTip">six</div>
<div class="singleTip">seven</div>
</div>
</form>
</body>
</html>
Sunday, August 5, 2012
I've finally got around to formalizing on a command-line parse tool for C#. And the winner is...
Command Line Parser Library
Command Line Parser Library
Thursday, June 21, 2012
Determine which process has a file locked - Windows 7
Are you getting that "can't delete" or "can't rename" a file because it is in use message. On Windows 7 you can use the Resource Monitor (just type the name into the Start search box to find it) to easily find out which process has a file locked.
Start the Resource Monitor and switch to the CPU tab. Just type the file name into the Associated Handles search box and you will be able to see which processes have matching file names locked. To kill the process, just right-click and choose "End Process".
Easy as pie and all part of Windows 7.
Tuesday, June 12, 2012
Better regular expression for phone numbers (multiple formats)
I'm often surprised at how often websites only accept a specific format for phone number input (U.S.) so I thought I would post a more flexible input format.
We want to allow users to enter phone numbers in formats like:
(123) 456-7890
123-456-7890
123.456.7890
1234567890
Using a regular expression, we can allow all these formats and more.
Notice that we specify regular expression group names to easily pick up the phone number parts. In C#, this can be done like:
Finally, here the some C# code to kick things off.
We want to allow users to enter phone numbers in formats like:
(123) 456-7890
123-456-7890
123.456.7890
1234567890
Using a regular expression, we can allow all these formats and more.
^\s*[(]?(?<AreaCode>\d{3})[)]?(\s*|[.-])(?<Prefix>\d{3})(\s*|[.-])?(?<LineNumber>\d{4})\s*$
Notice that we specify regular expression group names to easily pick up the phone number parts. In C#, this can be done like:
Code:
string prefix = match.Groups["Prefix"].Value;
Finally, here the some C# code to kick things off.
Code:
Regex rePhone = new Regex(@"^\s*[(]?(?<AreaCode>\d{3})[)]?(\s*|[.-])(?<Prefix>\d{3})(\s*|[.-])?(?<LineNumber>\d{4})\s*$");
Match match = rePhone.Match("123.456.7890");
Console.WriteLine(match.Success);
Monday, May 21, 2012
Tuesday, April 10, 2012
Razor MVC3 Quick Reference (comparison with ASP.NET)
A good Razor quick reference page found by my friend Petro. It compares Razor syntax with ASP.NET for those migrating.
http://haacked.com/archive/2011/01/06/razor-syntax-quick-reference.aspx
http://haacked.com/archive/2011/01/06/razor-syntax-quick-reference.aspx
Monday, April 2, 2012
Nice cheat sheet on many HTML5 and CSS3 features
Here is a nice cheat sheet for some of the more requested items related to HTML5 and CSS3. Not too bad.
Stories In Flight
Stories In Flight
Sunday, April 1, 2012
ASP.NET generic content box with title and body
Here is a quick example of creating a simple ASP.NET web control that allow you to have a region/box that contains a title and body where each of three elements can each have their own CSS class.
You can use the content box in a web page like:
You can use the content box in a web page like:
Code:
using System.Web.UI.WebControls; namespace CarverPainting { public class ContentBox : Panel { public string CssClassBody { get { return base.CssClass; } set { base.CssClass = value; } } public override string CssClass { get { return ViewState["CssClassMain"] == null ? string.Empty : ViewState["CssClassMain"].ToString(); } set { ViewState["CssClassMain"] = value; } } public string CssClassTitle { get { return ViewState["CssClassTitle"] == null ? string.Empty : ViewState["CssClassTitle"].ToString(); } set { ViewState["CssClassTitle"] = value; } } public string Title { get { return ViewState["Title"] == null ? string.Empty : ViewState["Title"].ToString(); } set { ViewState["Title"] = value; } } protected override void Render(System.Web.UIHtmlTextWriter writer) { bool hasClass = !string.IsNullOrWhiteSpace(CssClass); bool hasClassTitle = !string.IsNullOrWhiteSpace(CssClassTitle); bool hasClassBody = !string.IsNullOrWhiteSpace(CssClassBody); // contentbox class writer.Write("<div{0}>", hasClass ? string.Format(" class=\"{0}\"", CssClass) : string.Empty); if (!string.IsNullOrWhiteSpace(Title)) { writer.Write("<div{0}>{1}</div>", hasClassTitle ? string.Format(" class=\"{0}\"", CssClassTitle) : string.Empty, Title); } base.Render(writer); // contentbox class writer.Write("</div>"); } } }
Using dotlesscss with Visual Studio and IIS
I've started to use LESS the dynamic stylesheet language with Microsoft's ASP.NET. For starters, it really does help write and maintain stylesheets. The .NET version can be downloaded at http://www.dotlesscss.org/.
I did however run into an issue when I deployed my development code to a production server. It turns out that the Visual Studio 2010 web server handles the dotlesscss DLL differently from IIS 7.5. In a nutshell, to use dotlesscss in both environments (local, production) without having to made changes to one of the environments the setup I use is:
I did however run into an issue when I deployed my development code to a production server. It turns out that the Visual Studio 2010 web server handles the dotlesscss DLL differently from IIS 7.5. In a nutshell, to use dotlesscss in both environments (local, production) without having to made changes to one of the environments the setup I use is:
- Set my web project to use IIS Express (separate download from Microsoft).
- Add the following items to my web.config file
xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="dotless" type="dotless.Core.configuration.DotlessConfigurationSectionHandler,dotless.Core" />
configSections>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<pages>
<controls>
<add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
controls>
pages>
system.web>
<system.webServer>
<handlers>
<add name="dotless" type="dotless.Core.LessCssHttpHandler,dotless.Core" path="*.less.css" verb="*"/>
handlers>
system.webServer>
<dotless minifyCss="false" cache="false" />
configuration>
Wednesday, February 29, 2012
Why does copy/paste not work with Remote Desktop
So what do I do when clipboard stops working when you are using Windows Remote Desktop?
Fixing the issue is pretty straightforward and involves a few basic steps.
That should get things going again.
Fixing the issue is pretty straightforward and involves a few basic steps.
- Load up task manager (right click taskbar and select Task Manager)
- Go to the Processes Tab
- Select rdpclip.exe
- Click End Process
- Go to the Application Tab
- Click New Task
- Type rdpclip
- Click OK
That should get things going again.
Subscribe to:
Posts (Atom)
Can't RDP? How to enable / disable virtual machine firewall for Azure VM
Oh no! I accidentally blocked the RDP port on an Azure virtual machine which resulted in not being able to log into the VM anymore. I did ...
-
Oh no! I accidentally blocked the RDP port on an Azure virtual machine which resulted in not being able to log into the VM anymore. I did ...
-
Here is a full test program that demonstrates how to use SharpZipLib to zip an XElement into a byte array. This allows you to transfer larg...