http-redirectdotnetnukedotnetnuke-moduledotnetnuke-7

Redirect to another control DNN


In my Page_Load event of my custom DNN module I retrieve the settings that I have stored using the following.

 if (((string)Settings["username"] != null) && ((string)Settings["username"] != ""))
  username = "";
 {
   username = (string)Settings["username"];
if (((string)Settings["password"] != null) && ((string)Settings["password"] != ""))
{
  password = (string)Settings["password"];
}
if (((string)Settings["baseServiceUrl"] != null) && ((string)Settings["baseServiceUrl"] != ""))
{
  baseServiceUrl = (string)Settings["baseServiceUrl"];
}
baseServiceUrl = "";

Now my question is how do I redirect it to my module settings(called settings.ascx) control if username, password or baseServiceurl is null.

I'm sure it's not as simple as Response.Redirect('settings.ascx');

my aim is to replace username = "";

with a snippet similar to Response.Redirect('settings.ascx');

Please help


Solution

  • Thanks again Chris, your answer is correct but I decided to get the settings of the module via the modal pop up. This is what I did to get the answer to get the javascript popup script and url i right clicked on the gear icon using google chrome an inspected the element.

    I then copied the contents the anchor tag href attribute, this looked a bit like

    href="javascript:dnnModal.show('http://localhost/TestPage/ctl/Module/ModuleId/417?ReturnURL=/TestPage&popUp=true',/*showReturn*/false,550,950,true,'')">
    

    In my default.aspx page I created an anchor tag without the href. I made it a server control by putting runat=server and adding an ID to it and made the visibility false (in my logic i make it visible if it does not meet my criteria)

    <a runat="server" class="btn btn-success" id="settingsLink" visible="false" > <img src="/images/action_settings.gif"><span>Settings</span></a>
    

    Next I create a method to dynamically build my link

    private string settingsUrlBuilder()
    {
        var s = new StringBuilder();
        var urlPartArray = TabController.CurrentPage.FullUrl.ToString().Split('/');
        var partUrl = urlPartArray[3].ToString();
        s.Append("javascript:dnnModal.show('");
        s.Append(TabController.CurrentPage.FullUrl.ToString().ToLower());
        s.Append("/ctl/Module/ModuleId/" + ModuleId.ToString());
        s.Append("?ReturnURL=/");
        s.Append(partUrl);
        s.Append("&popUp=true");
        s.Append("',/*showReturn*/false,550,950,true,'')");
        return s.ToString();
    }
    

    This is where i use the function in the page load

    settingsLink.HRef = settingsUrlBuilder();  settingsLink.Visible = true;