Pages

23 August, 2012

Removing HTML tags from Drop Down list

Hi people, got another tweak to show you.

Following a previous post Filtering lookup columns I've noticed that the selected value of a DropDown list shows HTML tags like this:


Nevertheless the items in the dropdown list are ok.


The question is, how to remove the HTML tags from the selected value?


1. Edit the form in Sharepoint Designer and Split the view
Now click on your DropDown list control, the code window should now pointing to the DropDown source code.


2. Edit the selectedvalue tag
You can now see that the tag selectedvalue is pointing to the Field Name, in my case "Tabela1".

selectedvalue="{@Tabela1}"

What you have to do is just changing this part of the code to

selectedvalue="{substring-before(substring-after(@Tabela1, '>'), '<')}"

And voilá save the form and try it out.

Just one note "Tabela1" is the field name, just change it to your case.

If you want to keep in touch, feel free to Subscribe to How I did it - Sharepoint Foundation 2010





9 comments:

  1. Hi,

    Thanks for your share but i've a problem.

    Disable HTML Tag ok, but in dropdownlist I have twice same result.

    When i change the value of datavaluefield="ID" by datavaluefield="Title" it solve my problem but when i save my new configuration there is a page with message error.

    Can you help me please ?

    Sorry for my bad english :)

    ReplyDelete
    Replies
    1. Hi, saddly I can't reproduce your problem. Could you please send me a screnshot of your problem.
      Would be a pleasure to help you.

      Delete
  2. but what happend if change the text of list Items of "Tabela1" lookup? It must be on ID I think

    ReplyDelete
    Replies
    1. I think the right way to select dropdown Item by Value not with text. The best way in my opinion is "{substring-before(substring-after(@Parent, '&ID='),'&')}". Pedro Alexandre Dinis Rosa kindly comment if I am on mistake.

      Delete
    2. Hi Syed, thanks for visiting my post.
      You got a good question there. Let me do some tests and I'll return to you the result.

      Delete
    3. Ok Syed, did some tests and just to refresh myself of this tip. The goal is to solve a problem caused by the tip "Filtering lookup columns" in Edit forms.

      I you use the tip in the respective article, you will see that when you edit an item, the field will have an url in HTML. In order to only show the value of the field you have to use the tip in this article.

      About your question, check that in the DropDown control options you selected fo "Select a data field for the value" the ID of the list and for the Display text the field that you want to show to the user.

      The option you posted would show the ID to the user and not the Display text you want.

      Give it a try and you will that it works fine.
      Remeber this is only for the Edit forms.

      Delete
  3. So I was having this same issue, posted on the Filtered Look Up post, then saw this string.

    The tip above "worked", but now, it displays the selected choice above the list of filtered choices, and if something different is selected, it won't save that way, it just reverts back to the original choice....

    HELP!!!

    ReplyDelete
    Replies
    1. Hi Tiffy and welcome. I'm not able to mimic your problem. But by the description your showed, it could be a problema not in the formula, instead in the connection to the datasource.

      Would like to help you, could you send me some screenshots of the Dropdown list Data Bindings and the selectedvalue formula?

      Delete
  4. Thanks Pedro Alexandre Dinis Rosa Your post is extremely worth full and I got the Idea to resolve my problem

    Thanks again & keep Posting...

    ReplyDelete