views:

1539

answers:

5

Hi, I have strange problem with sharepoint and ajax functionality. We have an UpdatePanel placed inside webpart. When partial postback occurs, page title gets missing.

We have found that temporary partial solution is to write title element into one line and not use any spaces or controls inside it..not even a literal control.

But we need some way to provide sommon title for all pages, so title would look like this: My default title - Current page title

Any ideas how to solve this?

A: 

Can you reproduce this outside of Sharepoint? Have you run Fiddler to check what is coming back from the server in the async postback?

Ray Booysen
A: 

Hi, this looks like pure sharepoint's problem..also it looks like just sites based on publishing page layout are affected.

I debugged response in firebug and for some reason it returns setting for page title, so response from server contains not just update panel information, but also empty page title.

I debugged our webparts and none of them plays with page title. I would suggest not to use publishing or just not use any controls inside title.

We are currently working on this issue in company i work for, so i'll upload uour findings when we figure out something.

drax
+2  A: 

I don't have a reference to the newsgroup post, but this is a known problem with publishing pages, as drax mentioned. The workaround I have used in the past is to hard code the title on the page - the metadata title being lost is part of the bug.

When hardcoding wasn't possible, I have used javascript to change the page title: document.title = "title fixup here";

Supposedly microsoft plans to fix this problem in the next sharepoint release.

+1: dirty workaround, but sometimes it has to be done...
vitule
thanks for your answer..we will propably implement some similar javascript fix, because it is not possible to hardcode page titles for us
drax
+3  A: 

I thought I would share my solution to this pesky issue. What I ended up doing was throwing down this handy little script I put put together below. You can put this in your custom page layout or custom master page. It works by wiring up an AJAX event handler to grab the title before AJAX changes it and then re-applies it using Darpy's code above. This allows for the proper page title to always show.

<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>
James
Thanks! This fixed my issue perfectly! I just wish I had mod privileges so I could fix your styling :)
Phairoh
formatting fixed.
James
A: 

Adding the following @ the begining of my webpart user control Fixed the issue

// 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. }

thanks ALOT :D

Miss ZerOne