Extending #Episerver.forms with URL QueryString/post Value Element

How to extend Episerver Forms with a hidden QueryString/HttpPost Value Element.

Published 22nd of May 2017
For Episerver Version 10 and Forms > 4.4

Security warning! Be aware of how you use url parameters. This may be a security risk. Use at own risk or not at all.

Had a case where I needed to save a PageId into a form, similar to an order functionality.

You need an Element model:

And the view (which is a copy of built in PredefinedHiddenElementBlock.ascx)

Save your view under views/shared/elementblocks/

When using the element, just fill in the “Predefined value” with the key used by Querystring or form post.

It pops up in the form elements pane:

And in onpage edit:

In email placeholder you’ll find #OrderId#:

Use it wizely with httpGet or HttpPost

More reading

SEO terms:

  • Hidden post value in element of Episerver Form
  • How to extend episerver forms with querystring value

Get page property from submitting page in #Episerver.Forms

How to read a querystring value from the referrer/hosted form page. Also how to read a page property from the submitting page.

Published 16th May 2017
For Episerver Version 10 and Forms > 4.4

By implementing IPlaceHolderProvider in the Episerver.Form.UI  Namespace > 4.4 you can use it to add your own implementation of the Placeholder tags in email, eg #yourelement#

You’ll need to add an ExtraPlaceHolder called eg #SomePageProperty# and then implement it under ProcessPlaceHolders.

Important to remember! All placeholders in ProcessPlaceHolders will be triggered on every submit, even if it is not used in that form.

In the submissionData object, you have a SYSTEMCOLUMN_HostedPage item, where the id of the page submitting is saved, this is what we’ll use.

In some scenarios you may want to read the referrer page querystring, this may be used with HttpUtility.ParseQueryString(requestBase.UrlReferrer.Query)[“key”]

!Security warning! Be aware of how you use url parameters. This may be a security risk. Use wisely or not at all.

In my next upcoming blog post I will show how you can save http posted values into hidden formelements, but also querystring values.

Gist: https://gist.github.com/LucGosso/08ebb442e42cbb7fe239afe63ea95df5

More reading:

SEO terms

  • Extending Episerver forms
  • Customize email