views:

93

answers:

0

Hello there,

Using ASP.Net MVC1 and am dynamically creating the html in a model that is then dropped into the view and rendered at run time.

My view is a single page that looks like this:

<%@ Page Language="VB"  Inherits="System.Web.Mvc.ViewPage" %>
<%=(ViewData("Content"))%>

This dynamically created content is mostly dropdownlist boxes in the format of

<form method=post action="/questions/nextBatch">
    <div id="text">What is your preferred drink?</div>
    <select>
      <option selected value="noSelect"> - Please make a selection -  </option>
      <option value="a" >Milk</option>
      <option value="b" >Coffee</option>
      <option value="c" >Tea</option>
    </select>
</form>

Is it is possible to perform validation on the dropdowns lists to ensure that a value has been selected? If any of the dropdownlists that still have the default value (the "please make a selection" text) the page is then redisplayed with the font colour of the question or dropdownlist box changed to say red?

I'm from the Webforms world and have made the switch over to MVC (which I really like!) and I know there are some pretty slick validation tools out there but you seem to have to account for them within the view itself.

I cannot pass a HTML helper through the viewdata of the controller as it does not render unless it has been coded directly into the view itself.

Also, I'm looking for a pure asp.net solution as I cannot use javascript due to accessiblity concerns. I can access all the values of the dropdowns without any problems throug the formscollection object but from there I'm a bit stuck.

Is there something out there that I'm missing?

Thank you so much in advance for any advice or help!