What Does the QueryString Method Do? Documentation for it?

kentico guy asked on March 18, 2020 21:59

I looked in the Kentico documentation for information on what this method does, but I was unable to find it when I did a search through the Kentico documentation, I don't see this method listed at all. I am mostly wondering what the "parameter" does in this context:

Let's say that this method is implemented as follows inside a transformation:

QueryString["parameter"],false)

it seems like a lot of these methods are either not in the documentation, or the documentation search feature isn't working.

EDIT: this is on the portal engine not MVC

Correct Answer

Brenden Kehren answered on March 19, 2020 18:22

The parameter is coming from a URL. For instance, http://www.mydomain.com/your-page?whereIsThisParamComingFrom=who-knows the parameter value in this URL is 'who-knows'. It's not a value stored in the database, it's simply made based on a URL that is most likely manually generated in a transformation or code.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Peter Mogilnitski answered on March 19, 2020 03:27

hard to guess from what you show. Is this a macro, c#? Can you publish the whole snippet.

P.S. I would assume if parameter is null , then use false as default value. Anyway I don't want to guess here

0 votesVote for this answer Mark as a Correct answer

kentico guy answered on March 19, 2020 15:39

This is inside of a button transformation:

  aRandomBool = CustomMacros.GetMeetingStatus(IntKey);
  if (!aRandomBool && !ToBool(QueryString["whatDoesThisParamDo"],false)) // << query some value?
  {
    registerButton = "<a href="https://aGenericSite.com/link">A Button</a>";
  } 
0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on March 19, 2020 15:40 (last edited on March 19, 2020 15:49)

There are a lot of methods undocumented, simply because they could change from version to version. If you check out the API Documentation you may find some of that there.

To attempt to answer your question, this syntax QueryString["parameter"],false) is incorrect. You're missing something before and/or after the statement. If you're using something like ValidationHelper.GetBoolean(QueryString["parameter"], false) this is a valid statement and will return a false value as a default if nothing is found or unable to convert the value to a boolean.

** UPDATE BASED ON YOUR ANSWER **
The syntax ToBool(QueryString["whatDoesThisParamDo"],false) is attempting to convert the querystring parameter "whatDoesThisParamDo" to a valid value, if it can't or the querystring is empty, it will return the default value of false.

1 votesVote for this answer Mark as a Correct answer

kentico guy answered on March 19, 2020 18:16

Thank you, where does that parameter come from "whatDoesThisParamDo" ? Is it a value in the database or a field property of the CMS.Document class? I guess a better parameter name would have been "whereIsThisParamComingFrom" ... where is this reflected in the database?

0 votesVote for this answer Mark as a Correct answer

kentico guy answered on March 19, 2020 19:26

excellent! Thanks so much

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.