tags:

views:

55

answers:

1

i have different different pages which i want to call from one controller action

here is what i've done

  public class TemplatesController : Controller
{
    public ActionResult Select(int id)
    {

        return View("Temp"+(id));


    }

}

i have different view pages like Temp1, Temp2, Temp3,..etc... the id is fetched properly but i think there is a problem in concatenation

i want final result to be

return view("Temp1");

in another case it would be

return view("Temp2");

so that these pages can be called without creating controllers for each of the pages.

pls help.!

+1  A: 
return View("Temp"+id.ToString());

The parameter is a String, so you can build the string up however you want.

string RetView = "Temp"+id.ToString();
return View(RetView);

so that these pages can be called without creating controllers for each of the pages.

Although i'm not sure if this is good practice, I suppose it depends on how many views you have.

Pino