Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts

Monday, June 11, 2012

ASP.NET Update Panel not reloading jquery

Issue: asp.net update panel not reloading custom jquery after a partial post back occurs.

Cause: The asp.net update panel reloads all the content within the content template tags, thus your custom jquery is not reloaded and never fired.

Solution: Add your custom jquery at the end of the request by using the page request manager object:

    var prm = Sys.WebForms.PageRequestManager.getInstance();

    prm.add_endRequest(function () {
        DOSTUFF();
    });

And problem solved, it's as easy as that.

I hope this helped you, it solved my problem.

Friday, July 23, 2010

SharePoint People Picker

Have you ever wondered if you can retrieve data like email, job title, etc, from the people picker control in SharePoint using Javascript? In short, yes it can be done and it is pretty simple.

Below is some javascript which accepts a parameter for the the position of the control, and returns the desired value.

function getEmailFromPoeplePicker(identifier)
{
var tags = document.getElementsByTagName('DIV');
for (var i = 0; i < tags.length; i++)
{
var tempString = tags[i].id;
if ((tempString.indexOf(identifier) > 0) && (tempString.indexOf('UserField_upLevelDiv') > 0))
{
var pplHTML = tags[i].innerHTML;
var valReturn = pplHTML.indexOf(">Email");
if (valReturn > 0)
{
pplHTML = pplHTML.substr(valReturn + 12);
var ValuePos1 = pplHTML.indexOf(">");
var ValuePos2 = pplHTML.indexOf("");
if (ValuePos1 > 0 && ValuePos2 > ValuePos1)
return (pplHTML.substring(ValuePos1 + 1, ValuePos2));
}
}
}
return null;
}

if you wish to return any other details from the people picker simply modify this line :

pplHTML = pplHTML.substr(valReturn + 12);

Change the substr value of 12 to the following :

29 For the mobile number
12 Gets the Job Title

This is only 3 of many examples of how it can be done, feel free to comment if you have found a better way.