2

Using SharePoint Designer, how can an inline rendering template be specified for a given SharePoint:FormField in a DataFormWebPart ? For example, I want to arrange a multiple lookup field vertically, instead of the default horizontal layout. I know I can do this with jQuery, but I'm looking for a pure HTML/markup solution.

I'm sure this is possible as I've done this before, but can't remember how (the blog I bookmarked with an example of what I'm trying to do is not available anymore). I recall the solution involved copying the HTML markup of the given control from DefaultTemplate.ascx, modifying it according to the requirements and then copying it somehwere inside the <SharePoint:FormField>markup. The solution could be fully performed in SharePoint Designer and did not involved any custom ascx control.

Thanks for your shedding some light on this.

1 Answer 1

1

Once again, answering my own question.

It turns out that it's easy. The file %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\CONTROLTEMPLATES\DefaultTemplates.ascx contains all the predefined rendering templates for all the SharePoint form controls.

In order to override inline in SharePoint Designer (so, no deployment of features/controls is required) the rendering template of a control, copy all what is inside the <Template></Template> tag of the <SharePoint:RenderingTemplate> and paste it in your custom form, inside the <SharePoint:FormField> whose template you want to override.

An example of overriding the default TextBox rendered for a field of type text:

<SharePoint:FormField runat="server" FieldName="MyField" Id="ff1{$Pos}" __designer:bind="{ddwrt:DataBind('i',concat('ff1',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@MyField')}">
    <Template>
      <asp:TextBox id="TextField" maxlength="255" runat="server"/>
     <!-- get rid of this annoying <br/>  tag -->
    </Template>
</SharePoint:FormField>

Now, your FormField will be rendered as TextBox, without the annoying <br> tag that is normally put after it.

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.