I want to add this to an SPListItem HTML field (Multiline text)

<a href="#" onclick="OpenDispPage('Table 1.1', 'table');" >Text</a>

and this is what SharePoint makes out of it when I submit

<a href="#">Text</a>

Is this because my field is multiline and not Full HTML or are there any other constraints I'm missing?

Many thanks

  • Just so I'm clear, you have a Multiline Text field on a list and when you set an item's property to the html fragment above it reformats it strips out the onclick?
    – Rob D'Oria
    Commented Jul 31, 2011 at 16:28

1 Answer 1


Your not going to be able to do this with the Multiline Text field type. Anything other than RichTextMode=FullHtml won't even render the contents as HTML (i.e. you won't see the link) and if you set the field to FullHtml the HTML is altered when the item is saved...this happens with pretty much any implementation of the InputFormTextBox control.

One possible workaround is to put your javascript (...OpenDispPage) into an HTML file that you drop in the 14\Template\Layouts and then reference it in a Hyperlink field instead of Multiline field. So something like this for the URL in the Hyperlink field:


Where the arguments to OpenDispPage are passed on the querystring and then the HTML would look something like this:

    <script language="javascript" type="text/javascript">
        OpenDispPage(getQueryString("a"), getQueryString("b"));

        function getQueryString(name) {
            var q = window.location.search.substring(1);
            var qs = q.split("&");
            for (var i = 0; i < qs.length; i++) {
                var parts = qs[i].split("=");
                if (parts[0] == name)
                    return parts[1];

            return null;

        function OpenDispPage(a, b) {
            alert(a + "," + b);

I think that's pretty clean, but without knowing exactly what you're trying to do I may be way off.

  • Hi Rob, I'm actually writing code to convert Open XML data into HTML, where each section gets it's own SPListitem object in an SPList, the table and figure stylings would be converted into linkbuttons that open up a modaldialogbox pinpointing extracted table/figure data. Because these are just blocks of text and not seperated it would all have to fit into one field. In any case, many thanks for your invaluable help, Commented Aug 1, 2011 at 6:53

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.