I have created a visual webpart. In that I created a SharePoint form field control instead of asp.net textbox.

I am not able to apply styles to this control and it's not looking good in the form. How can I style this control?

<sharepoint:FormField ID="formfield1" runat="server" ControlMode="New" OnInit="listitems_Init" ListId="ecaf0841-5628-4fe5-9126-dccb79090d91"></sharepoint:FormField>

If I give css class="class1" it is not affecting and also it is disabled from the UI.

1 Answer 1


CssClass should be one word not splitted. If that doesn't work try this:

Wrap your control in a div or span, then apply your CSS.

<span class="mycontrol">
 <SharePoint:FormField CssClass="mytextbox" ID="FormField1"..... </SharePoint:FormField>


span.mycontrol input[type="text"] // change input type based on your control
  border: 1px solid #ddd;
  padding: 5px;
  • Thanks. This worked for me, but its so annoying I can't assign my css through CssClass, I have to wrap the sharepoint control in some other html css, then assign it through that. Lame. Aug 6, 2015 at 20:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.