Problems with querystrings

Vote:
 

Hi

How can I build a correct link that includes querystring parameters? and how can I get the querystring parameters on the receiving page.

I have a

PageData page;

And try to change LinkUrl for that page like this:

page.LinkURL = UriSupport.AddQueryString(page.LinkURL, "?docid=", DocumentId)

and then I use Request.QueryString["docid"] 

but I only get the querystring  {&id=13515&epslanguage=sv} 

Thanks for your help.
#57434
Mar 14, 2012 13:55
Vote:
 

Hi,

page.LinkURL already contains parameters (id, epslanguage and so on). So you cant pass ?-sign in the parametername. This should be correct:

string url = UriSupport.AddQueryString(page.LinkURL, "docid", DocumentId);

Which would result in /Templates/Page.aspx?id=13515&epslanguage=sv&docid=12345

Why do you set the page.LinkURL?

#57435
Mar 14, 2012 14:57
Vote:
 

You could also do this directly in you template (aspx-file).

<%= CurrentPage.LinkURL + "&docid=" + DocumentId %>

    

#57436
Mar 14, 2012 14:59
Vote:
 

Hi

I doesn't work. I use a PageList and for every page I create in that list I show the same page but with different content that’s why I need to change the LinkURL.

Here is the code

//delete pages before create new
 DataFactory.Instance.DeleteChildren(rightMenu.PageListRoot, false, AccessLevel.Delete);

foreach (DocumentList docList in medicalSourceDocumentsList)
{
     pagelink = DataFactory.Instance.GetDefaultPageData(rightMenu.PageListRoot, 44);
       
     clonelink = pagelink.CreateWritableClone();
     clonelink.PageName = docList.DocumentTitle;                                   

     clonelink.Property["Title"].Value = pageListControl.CurrentPage.Property["Title"].Value;
    clonelink.Property["RootPage"].Value = pageListControl.CurrentPage.Property["RootPage"].Value;                
                 
  //Build querystring
  clonelink.LinkURL = UriSupport.AddQueryString(clonelinkSeeAlso.LinkURL, "docid=", docList.DocumentId);                    
                                                                               
   DataFactory.Instance.Save(clonelink, SaveAction.Publish, AccessLevel.Read);
   linkDataCollection.Add(clonelink);                   
  }

               pageListControl.DataSource = linkDataCollection;
               pageListControl.DataBind();

 

#57454
Mar 15, 2012 8:53
Vote:
 

Ok. Deleting and saving pages is kinda time consuming, so it's not recommended to do that on every rendering.

I'm not sure you can save a page with another LinkURL. And in your code I don't think the LinkURL is generated yet, because it needs a roundtrip to the database to get an id to the page.

I would recommend using my other solution, adding the docid on rendering in the pagelist instead. You can store the docid in a property on the page.

<%# Container.CurrentPage.LinkURL + "&docid=" + Container.CurrentPage["DocumentID"] %>

    

 

#57455
Edited, Mar 15, 2012 9:04
Vote:
 

You can also set an external link on the page.

 

cloneLink.LinkType = PageShortcutType.External;
cloneLink["PageExternalURL"] = UriSupport.AddQueryString(clonelinkSeeAlso.LinkURL, "docid", docList.DocumentId);

PageExternalURL is a built-in property that you find on the 'Category' tab in edit mode.   And you should not have a ? or = in your queryparameter name.

#57457
Mar 15, 2012 9:12
Vote:
 

Thanks for your help, I will try this.

#57501
Mar 16, 2012 7:47
Vote:
 

Did this solve your problem Margareta?

#57774
Mar 27, 2012 13:32
Vote:
 

Yes i solved it by using querystrings and change the view depending on the id instead of creating pages.

#57790
Mar 28, 2012 7:42
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.