The jquery TOOLS library has a nice API for creating HTML5 range inputs in older browsers. And the MVC 2 framework for ASP.NET offers a nice way of creating interactive web applications for Windows servers. The logical thing to do, then, is combine them somehow.
First we'll create custom .NET attribute called StepSize that we can attach to a model property. This attribute will be used to determine the step attribute of our range input. We'll use the existing .NET Range property attribute to determine the min and max values of our range input.
Next, we need some HtmlHelper extension methods to create the range input on our views. We'll create a strongly-typed version of this method and use reflection to traverse the model's property for which we're building the range input. These methods return an MvcHtmlString which means all the contents have been encoded and are ready to be displayed.
Once all that compiles, we can simply write the following line in our view to get a nice range input (which can be styled with CSS.)
<%= Html.RangeInputFor(model => model.SomeProperty) %>
Of course, you'll need to make sure your jquery TOOLS functions are set up correctly. I'm just using this simple call in my $(document).ready() function:
As always, check the code before you use it. I don't guarantee that these methods won't allow Satan himself to spawn in your web page and ruin the internet.
<span style="color: rgb(6, 0, 255); font-weight: bold; ">namespace</span>
<span style="color: rgb(6, 0, 255); font-weight: bold; ">using</span>