SharePoint: Change the “No Items” message in a discussion web part


Yet another Content Editor Web Part (CEWP) trick…

But you can also add it to the master page!


When you create a new team site or add a new discussion list to a site the discussion web part displays a "no items" message. If you would like to change this message all you need is a little JavaScript added to the web part page or to the master page. If you would rather hide this web part anytime there are no discussions then see the previous customization: "Hide a web part with zero rows".







Add a Content Editor Web Part to the page with the discussion web part and using the Source Editor button (2007) paste the following JavaScript.  For 2010 or 2007 create a text file in a library with this JavaScript and link to it from the Content Editor Web Part.

<script  type="text/javascript">

function ChangeDiscussionMessage()

  var a = document.getElementsByTagName("TD");
  for ( var i=0; i<a.length; i++ )
    if (a[i].className=="ms-vb")
      if (a[i].innerHTML.indexOf("There are no items to show in this view")>-1 &&
          a[i].innerHTML.indexOf("discussion board")>-1)
         a[i].innerHTML = "There are no active discussions";








Bil Simser said...

Consider the one line jQuery version for less code. It also runs before the user sees the page so it doesn't show the original text then the new text.

(note: wrap this with a script tag, script not allowed in comments)

$("td .ms-vb:contains('There are no items to show in')").text('There are no active discussions');

Mike Smith said...


jQuery is elegant and brief. If you are already using jQuery in your site, or are loading it from your master page, then it is the quick solution. Otherwise this one line of code needs to be combined with the download of the jQuery library, which for many users without server or SPD access implies that it must also be uploaded to a site library.

If you have any other jQuery solutions to any of my JavaScript tricks, please post them here! Somewhere there's always at least three solutions to every problem...


Bil Simser said...

Hi Mike,

Yes, there's always a better way to skin a cat (or SharePoint). I like jQuery for it's elegance and find regular JavaScript just klunky. It's true that if you don't have jQuery installed you need to include that but IMHO *all* SharePoint sites should install it as it's a life saver for doing simple things like this with little effort.

BTW I posted a new blog post in response to this one here:


Bob said...

Can this work with a list view as well? If so, what do I have to change? (I'm not a developer, please excuse my ignorance!)

Mike Smith said...


Sure... just replace the text "There are no items to show in this view" with part or all of the text displayed in the web part and the text "There are no active discussions" with your new message.

For example, for a links list for vendor links change the first block of text to "There are currently no favorite links" and the second block of text to "No vendors links available"


Anonymous said...

The jquery version of this fix works great in SPD - thank you for the simple solution :)

GJ said...

I used this piece of code on my SharePoint 2010 page and it worked but only for a minute :(
My page has 3 lists named Today, Last 7 Days and Last 30 Days that display some sales data. I have disabled the Editor Toolbar for each of them and have configured the list web parts to refresh every 60 seconds under the AJAX options offered by SP 2010.
The 'There are no items to show ...' text appeared on the 'Today' list till an entry is pushed to our database. After reading your post, I added a Content Editor web part to my page and used your code to replace it however; after a minute - the list web parts refresh and the text changes back to default :(
To see the 'new' text again, I have to manually Refresh the whole page which is not convenient. It would be great if you could provide some solution.

Mike Smith said...


The refresh option you turned on is reloading the entire web part once a minute. The JavaScript in my example runs only once. We would need to find a way to hook into the the AJAX code and then run my code after each reload. I'll add to my "to-do" list, but it will probably be a while...


GJ said...

Hey Mike,

Thanks for the positive response. The other lists have the AJAX option but the Content Editor Web Part does not so I am waiting for your updated code.

- GJ

Freeheel said...

The other option is to set ParameterBinding location value to point to custom resource file (easily with SP Designer) and then put custom resource file to App_GlobalResources folder.

Brown Michael said...


I have two filtered through connection library webparts that show this similar text when no documents are displayed. I used your code for each WP in one CEWP, but it only hides the text in the 2nd WP. I then created a second CEWP; one under each of the library WPs and still only the 2nd WP text is hidden. Each CEWP is tagged to specifically look at the Library WP above it. Any thoughts? Can you only hide the text from one WP in a WPZone?

Thanks, Michael

Note to spammers!

Spammers, don't waste your time... all posts are moderated. If your comment includes unrelated links, is advertising, or just pure spam, it will never be seen.