Get the query string value in Kentico 12SP Form text input field.

kumar GANJI asked on November 18, 2021 14:28

Hi, I am using Kentico forms to create a form. I need to use the value of the query string in one of the text input in the form which will be hidden and When user submits the form, the value of the hidden field should also be submitted with the form.

Currently I am not able to bind the value of query string in my form field. I have tried to put the value of the query string in the default value parameter of the form field by using the macro expressions like {% Request.QueryString["QueryStringParamName"]|(identity)GlobalAdministrator%}. Both of these macro expressions are not working for me.

Recent Answers


Juraj Ondrus answered on November 18, 2021 14:49

You need to use the small black arrow next to the default value field to enter a macro expression. Then, you can use one of these two macros:

{%QueryString["parameterName"]%} or,
{%ParameterName%}

Make sure you will sanitize the input and use e.g. some default value too.

0 votesVote for this answer Mark as a Correct answer

kumar GANJI answered on November 18, 2021 17:20

  • Hi @JurajOndrus I tried the above mentioned way but it is giving the default value all the time.
  • {% QueryString.GetValue("parameterName","Default")%}
  • my URL format is /home&ParameterName=(value)
0 votesVote for this answer Mark as a Correct answer

vasu yerramsetti answered on November 18, 2021 19:17 (last edited on November 18, 2021 20:32)

Try this -

{%ParameterName%} for parameter

{% QueryString %} for get Query string

Reference - https://docs.xperience.io/k11/macro-expressions/macro-syntax

https://devnet.kentico.com/questions/split-on-querystring-using-a-macros

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on November 19, 2021 05:20

Kumar, try using the syntax from my first post. No need to add GetValue method.

0 votesVote for this answer Mark as a Correct answer

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