views:

35

answers:

2

I am writing a questionnaire application with ASP.NET MVC 2.

I have a set of questions that require a response of yes, no, unsure.

These need to be images that return a value to the questionnaire controller.

What is the best approach for adding image buttons?

+1  A: 

I'd go with creating an ImageButton HtmlHelper.

http://www.asp.net/mvc/tutorials/creating-custom-html-helpers-cs

Yakimych
+1  A: 

This is long path of misery, where you will encounter IE differences from firefox, outrageous numbers of forms, image maps, violating HTTP with using image links instead.

Take it from me, save the fruitless journey: Use a regular button and use CSS to style in the image.

Give your buttons a name and a value:

<input type="submit" name="submitButton" value="Yes" class="YesImage" />
<input type="submit" name="submitButton" value="No" class="NoImage" />

Then in your controller:

[HttpPost]
public ActionResult Something(string submitButton)
{
    switch (submitButton)
    {
        case "Yes":
            //do something
            break;
        case "No":
            //do something else
            break;
    }
}
BritishDeveloper