How to Remove {generate-id()} from a Customized Form in SharePoint

If you’ve done much work using custom forms in SharePoint, you’ve probably run into the {generate-id()} bugaboo. For reasons that I’ve not been able to determine, if you use an id attribute in any HTML element, SharePoint Designer adds the {generate-id()} string to the end of the name you’ve set. Here’s an example. If you code this:

<input id="SubmitButton" type="button" onclick="javascript:DoSomething()" Value="Submit" />

when you save the page, Designer converts your code to:

<input id="SubmitButton{generate-id()}" type="button" onclick="javascript:DoSomething()" Value="Submit" />

Not all that helpful. I found a nice fix for this from Jorge (El Che) Vasquez. Simply create an empty dummy variable, like:

<xsl:param name="DummyParameter" />

and append it to your id attribute:

<input id="SubmitButton{$DummyParameter}" type="button" onclick="javascript:DoSomething()" Value="Submit" />

Designer will then give you what you wanted in the first place.

Check out Jorge’s blog post for a richer explanation of this if you need more details.

Similar Posts

17 Comments

  1. Folks, I am having the same issue. Designer replaces my ID with {generate-id()}. I started seeing it after my IT department did a patch push. Now the question is, which patch created this mess? I am going to try your suggestions to see if it will work.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.