Dynamically prefill hidden element of Episerver Forms

lockevn
1 min readMar 14, 2017

--

We know about the hidden predefined form element. In Chrismas, we can use it (create and set a predefined-hidden-element, value = “Xmas”) to “tag” the form submission in the period from1st December to 25th December. Then remove it after X’mas.

It is somehow possible to have an element pre-populated with dynamic data.

For example

  1. Use VisitorData API to get information of Visitor (Geolocation, IP, …). It evaluation and setting data can be executed on clientside (JS) or serverside (C#).
    - Geolocation and browser-capabilities can be guess by JS script.
    - C# code can inspect the HttpRequest which send to server to render the form.
    - implemented by VisitorDataHiddenElement
  2. If we want to prefill by calculation and take from other datasource (ask for Facebook profile link, and we need to count number of reaction on his cover photo), use Autofill API (to calculate and autofill to a hidden element).

Guide of how to use these API is available on Episerver’s github, Samples and Demo project

If this post helps you or saves your time, please go buy me a beer ;)

--

--

lockevn
lockevn

Written by lockevn

Developer, Sportman. Write code with joy, bake app with heart. Opinions are my own. If you feel I save your time, go http://BuyMeACoff.ee/Lockevn

No responses yet