I basically have several input fields that share the same last 3 characters, “Max”. They are all different from the “div” tags they are part of. The block of code I have right now looks terrible:
if (Convert.ToInt32(Request.Form["MCQMax"]) > 0)
{
TempData["Max"] = Convert.ToInt32(Request.Form["MCQMax"]);
}
else if (Convert.ToInt32(Request.Form["SAMax"]) > 0)
{
TempData["Max"] = Convert.ToInt32(Request.Form["SAMax"]);
}
else if (Convert.ToInt32(Request.Form["PLMCQMax"]) > 0)
{
TempData["Max"] = Convert.ToInt32(Request.Form["PLMCQMax"]);
}
else if (Convert.ToInt32(Request.Form["PLIFMax"]) > 0)
{
TempData["Max"] = Convert.ToInt32(Request.Form["PLIFMax"]);
}
else if (Convert.ToInt32(Request.Form["PLDMax"]) > 0)
{
TempData["Max"] = Convert.ToInt32(Request.Form["PLDMax"]);
}
How do i pass in any form elements that end with Max instead of having this redundant block of code?Thanks guys!!
Something like this:
[Edit]
I’m sorry didn’t pay enough attention. I think this is what you need: