Try our conversational search powered by Generative AI!

Episerver.Forms - add a css class to a form field



I created a form using episerver. forms. I would like to add a css class to a form field. Anyone knows how can I do that?

Thanks in advance,


Apr 18, 2016 14:28


Have you read this? > Creating a form > 2. Adding form fields ?

Edited, Apr 18, 2016 18:36
<p>Depending on which field type you want to add your css class to, you'll need to copy its view from the folder modules\_protected\EPiServer.Forms\Views\ElementBlocks</p> <p>to ~/Views/Shared/ElementBlocks and make your customization on the markup.</p> <p>Have a look at my blog post where I mention the basics of extending forms:&nbsp;<a href=""></a></p>
Apr 18, 2016 19:23

Thanks Alf Nilsson,

I did exactly what you said, I copied TextboxElementBlock.ascx from modules\_protected\EPiServer.Forms\Views\ElementBlocks to ~/Views/Shared/ElementBlocks, exactly with the same name and then I added one text element to my form but I don't see my changes. it seems my new view is being ignored.

I also checked Forms.config and seems ok. 

<episerverforms minimumAccessRightLevelToReadFormData="Edit"

Apr 19, 2016 13:51

Hi Again,

I don't know what changed but I had to close my Visual Studio and when I opened again it starts working.

Thanks a lot. Your blog is really helpfull.


Apr 19, 2016 14:19

It's not about Visual Studio.

ASP.NET try to find the view from 

  • formElementViewsFolder="~/Views/Shared/ElementBlocks"
  • then from modules\_protected\EPiServer.Forms\Views\ElementBlocks
  • Once it found the view, it will never do finding again (kind of caching). All you need to do is restart your website/rebuild your project to start the ASP.NET application again.
May 09, 2016 13:24

We ran into an issue where in our production domain formElementViewsFolder="~/Views/Shared/ElementBlocks" is not being honored. We have restarted the website multiple times. It works on our internal site but not on our public facing site. modules\_protected\EPiServer.Forms\Views\ElementBlocks has no views in it and only ~/Views/Shared/ElementBlocks has the views.

Edited, Feb 12, 2021 17:07
* 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.