Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Multiple Views with QueryStringsMultiple Views with QueryStrings
Previous
 
Next
New Post
8/5/2007 12:58 PM
 

Hi,

I know this is covered in bits around this Forum and through that I think I am close to solving this - but I am not quite there!

I have:
Events.ascx - this control will just have a place holder which will load the other controls depending on the querystring.

ViewEvent.ascx - this control simply displays the detail of the event.
EditEvent.ascx - this control will be used to create and edit events, depending on the querystring.  It is registered twice in the module definition.  Once with a control key of createevent, the other, editeven.t

<code>

In my Events.ascx I have the following:

protected void lnkCreateEvent_Click(object sender, EventArgs e)
    {
        Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(
            PortalSettings.ActiveTab.TabID,
            "createevent"
        ));

    }

which takes me to a URL:

http://localhost/GJ/Gigs/tabid/58/ctl/createevent/Default.aspx

and I don't see the ascx file I expected.

If you look at the code below, I haven't got very far as

string controlType = Request.QueryString.Get("ControlType");

is empty. I think I have managed to get very confused.  Anybody with any best practice advise?

 

--------------------

My Event.ascx contains the following:

<code>

protected void Page_Init(object sender, System.EventArgs e)
    {
        string controlType = Request.QueryString.Get("ControlType");

        m_controlToLoad = GetControlToLoad(controlType);

    if (m_controlToLoad != null)
        {
            LoadControlType(m_controlToLoad);
        }
    }


  private void LoadControlType(string controlToLoad)
  {
      PortalModuleBase portalModuleBase = (PortalModuleBase)this.LoadControl(controlToLoad);

      if(portalModuleBase != null)
      {
          portalModuleBase.ModuleConfiguration = this.ModuleConfiguration;
          portalModuleBase.ID = System.IO.Path.GetFileNameWithoutExtension(controlToLoad);
          plhControls.Controls.Add(portalModuleBase);
      }
  }

 

private static string GetControlToLoad(string controlType)
    {
        string controlToLoad;

        if (string.IsNullOrEmpty(controlType))
        {
            controlToLoad = "Event.ascx";
        }
        else{
            switch (controlType.ToLower())
            {
                case "createevent":
                    controlToLoad = "EditEvent.ascx";
                    break;
                case "editevent":
                    controlToLoad = "EditEvent.ascx";
                    break;
                case "viewevent":
                    controlToLoad = "ViewEvent.ascx";
                    break;
                default:
                    controlToLoad = "Event.ascx";
                    break;
            }
        }

        return controlToLoad;
 
    }

</code>

 
New Post
8/5/2007 3:05 PM
 

I used the example in this link to load dynamic controls.  It is VB but you should get the idea.

Carlos

 

 
New Post
8/5/2007 3:15 PM
 

Although I would not recommend using NavigateUrl to pass the control type to be loaded in the "ctl" querystring parameter (because it could conflict with DNN's use of this parameter", it would appear that the reason that

string controlType = Request.QueryString.Get("ControlType");

is returning an empty string is that the parameter key created by NavigateUrl is "ctl" not "ControlType". So, your code would need to be:

string controlType = Request.QueryString.Get("ctl")


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
8/5/2007 10:12 PM
 

Imagemaker: Why don't you recommend it? NAvigateURL is the easiest way to load controls without worrying about anything else. Together with EditURL, it is one of the best examples of code reuse and refactoring. It dynamically builds the apropriate URL. That being said there's two approaches.

  1. Loading controls defined in DNN needs two parameters, the tabid and the moduleid so DNN knows where to load your control. It will use the module's settings automatically.
  2. Loading controls dynamically. It's not necessary to define the controls in DNN, but the developer needs to handle someother details as the control is loaded dynamically.

I think the original poster got confused because he was using  mixture of both approaches.


Do you know the truth when you hear it?
Néstor Sánchez
The Dúnadan Raptor -->Follow Me on Twitter Now!
 
New Post
8/6/2007 1:19 PM
 

After re-reading my post, I agree that the concern I expressed about using NavigateURL in this manner was not clear.  I have no problem with using NavigateURL (or EditUrl) as appropriate - in fact use them all the time.  What I don't recommend is using the 'ctl' key in the querystring to pass which user control is to be loaded dynamically as this may (as you say mixing both approaches) cause conflicts with DNN's own use of this parameter.


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Multiple Views with QueryStringsMultiple Views with QueryStrings


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out