mvc 3 partial vs ascx

I am working on converting web form to mvc 3
one of the issues I have is ascx. Currently, our web form web app has a folder contain all ascx

It is okay for me to re-write those, but I would like to learn the best approach.
e.g.

if request.querystring("type") = "life insurance"
  show lifeinsurance.ascx
else if request.querystring('type") = "auto insurance"
  show autoinsurance.ascx
else
 show somethingelse.ascx

1. In mvc 3 world. what can I do?
2. Assume each ascx has different html control. How can I collect the value?
solution1368Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Carl TawnSystems and Integration DeveloperCommented:
You can output a partial view based on it's name. So you could try adding the querystring value into the PropertyBag for the view, or as part of your model, and having it drawn dynamically from that:
@{ Html.RenderPartial(PropertyBag.Type); }

Open in new window

0
solution1368Author Commented:
can you show me the codes based on my situation? I just need to know how it works...
0
Carl TawnSystems and Integration DeveloperCommented:
Very simply, you'd be looking at something along the lines of:
// Controller action
public ActionResult Index()
{
    ViewData["Mode"] = "LifeInsurance";       // default

    // set partial view name from querystring
    if (Request.QueryString["type"] != null)
        ViewData["Mode"] = Request.QueryString["type"];

    return View();
}

Open in new window


Then in your view:
@{ 
    Html.RenderPartial(ViewData["Mode"].ToString()); 
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.