Q:

How do I use an ASP.NET MVC 3 DNN Module on different pages but passing different parameters?

How do I use an ASP.NET MVC 3 DNN Module on different pages but passing different parameters? My requirement is to develop a DNN module using ASP.NET MVC that lists cities based on province. On another page I need to list all Lecturers based on a department. I don't want to design 2 modules that only vary on what parameter is passed.

A:

The way I would do this is with a module setting that allows a content administrator to use your module, but with different behavior on different pages based on the value of the module setting.  To see a working implementation of module settings in an MVC module, download my GitHub Restaurant Menu MVC project.
If, for example, your setting is called "Data Source" and you allow the user to select from a drop down list of data source options (ie: "Regions", "Lecturers", etc) in your settings module view, that will update a setting value for your module instance.
Then in your main view controller, you can get that setting and change the model to use the proper data source.  That data source will generically be used by your view to present a cascading set of drop downs (or however you want the UI to present the hierarchy data).
Here is a rough example:
public ActionResult Index()
{
    string dataSrcSetting = "region";
    if (ModuleContext.Settings.ContainsKey("Data_Source"))
    {
        dataSrcSetting = ModuleContext.Settings["Data_Source"].ToString();
    }

    // Get model
    var model = new HierarchyDataModel();
    if (dataSrcSetting.Equals("region")) 
    {
        model.ParentData = businessLogic.getCountries();
        model.ChildData = businessLogic.getRegions();
    } 
    else if (dataSrcSetting.Equals("lecturer")) 
    {
        model.ParentData = businessLogic.getDepartments();
        model.ChildData = businessLogic.getLecturers();
    }

    return View(model);
}

