Sharepoint, ajax and page title

I have a strange problem with sharepoint and ajax function. We have an UpdatePanel hosted inside the webpart. When a partial postback occurs, the page title is missing.

We found that a temporary partial solution is to write the title element on one line and not use any spaces or controls in it. Even a literal control.

But we need to somehow provide the name of the catfish for all pages, so the title will look like this: My default title is the name of the current page

Any ideas how to solve this?

+3
source share
5 answers

I don't have a link to a post in a newsgroup, but this is a known issue with publishing pages, as mentioned in drax. The workaround I used in the past is the hard code of the page header - the lost metadata is part of the error.

When hardcoding failed, I used javascript to change the page name: document.title = "title fixup here";

Microsoft is supposedly planning to solve this problem in the next release of sharepoint.

+3
source

I thought I would share my solution to this unpleasant problem. What I ended up with is resetting this handy little script that I put below. You can put this in your own page layout or custom homepage. It works by hooking up an AJAX event handler to grab the header before AJAX changes it and then applies it again using the Darpy code above. This allows you to always show the correct page title.

<script type="text/javascript"> // This script is to fix the issue where AJAX causes SharePoint // publishing pages to sometimes make the page title something // whacky. var app = Sys.Application; var origTitle = ""; app.add_init(SPCustomAppnInit); function SPCustomAppnInit(sender) { origTitle = document.title; // grab the original title. var prm = Sys.WebForms.PageRequestManager.getInstance(); if (!prm.get_isInAsyncPostBack()) { prm.add_pageLoaded(SPCustomPageLoaded); // wire up loaded handler. } } function SPCustomPageLoaded(sender, args) { document.title = origTitle; // put the original title back on the document. } <script> 
+5
source

I understand that this has already been answered, but I'm going to throw my $ .02. It seems that the problem is due to two conditions: (1) using asynchronous AJAX postback and (2) with a multi-line header <title> element in the <head> of the page.

Check your homepage. If he has something like that:

 <title> <sharepointwebcontrols:listitemproperty property="Title" ...> </title> 

... then change it to one line, for example:

 <title><sharepointwebcontrols:listitemproperty property="Title" ...></title> 

The problem is resolved. No javascript required.

+3
source

it looks like a clean sharepoint issue. It also seems that only sites based on the publication of the page layout are affected.

I am debugging the response in firebug and for some reason returns the parameters for the page title, so the response from the server contains not only information about the update panel, but also an empty page title.

I debugged our websites, and none of them reproduced the page title. I suggest not using publications or just not using any controls inside the header.

We are currently working on this issue in the company I work for, so I will upload your results when we come up with something.

0
source

Adding the following @ to the top of my custom website element Fixed issue

 <script type="text/javascript"> // This script is to fix the issue where AJAX causes SharePoint // publishing pages to sometimes make the page title something // whacky. var app = Sys.Application; var origTitle = ""; app.add_init(SPCustomAppnInit); function SPCustomAppnInit(sender) { origTitle = document.title; // grab the original title. var prm = Sys.WebForms.PageRequestManager.getInstance(); if (!prm.get_isInAsyncPostBack()) { prm.add_pageLoaded(SPCustomPageLoaded); // wire up loaded handler. } } function SPCustomPageLoaded(sender, args) { document.title = origTitle; // put the original title back on the document. } </script> 

thanks ALOT: D

0
source

All Articles