og:description and google plus not working anymore - facebook-opengraph

According to google plus documentation and other questions, the following code should add a default description when sharing:
META:
<meta property="og:title" content="TITLE HERE" />
<meta property="og:image" content="https://si0.twimg.com/profile_images/604644048/sign051.gif" />
<meta property="og:description" content="DESC HERE" />
<meta name="description" content="DESC HERE" />
HTML
<div class="g-plusone" data-annotation="inline" data-width="300"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
However, while the image and the title work, there is no description when sharing.
The code above is also on jsfiddle.

Related

_doPostBack added twice. one by manual and one by gridview in asp.net

I have a page where i am rendering GridView. In GridView i have a CheckBox and once you check, uncheck, Jquery Dialog appears and i need a postback event on that dialog. so i am adding a manual postback on that page. everything is fine till gridview has only 1 page. as soon as gridview has more records, it add a _doPostBack method on page. so i now have a 2 _doPostBack method on page and nothing works because of this.
How can i define in my page that i do not want to add any _doPostBack method by any controls because i have already defined it manually?
Here is my HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1">
<title>Store Management</title>
<script src="/js/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="/js/jquery-ui.min-1.10.1.js" type="text/javascript"></script>
<link href="/assets/styles/StorePortal/style-22012013.css" rel="stylesheet"
type="text/css" />
<link href="/assets/styles/StorePortal/jquery-ui.css" rel="stylesheet"
type="text/css" />
<link href="../App_Themes/AbleCommerce/ComponentArt.css" rel="stylesheet"
type="text/css" />
<link href="../App_Themes/AbleCommerce/print.css" rel="stylesheet" type=
"text/css" />
<link href="../App_Themes/AbleCommerce/style.css" rel="stylesheet" type=
"text/css" />
<link href="../App_Themes/AbleCommerce/webparts.css" rel="stylesheet" type=
"text/css" />
</head>
<body>
<form action=
"portal.aspx?q=bbaae796d951c95311f5ec3e599784079c6093ee&q1=COV" id=
"form1" method="post" name="form1">
<div>
<input id="__EVENTTARGET" name="__EVENTTARGET" type="hidden" value=
"" /> <input id="__EVENTARGUMENT" name="__EVENTARGUMENT" type=
"hidden" value="" />
</div><script type="text/javascript">
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
</script>
<div>
<input id="__VIEWSTATEENCRYPTED" name="__VIEWSTATEENCRYPTED" type=
"hidden" value="" />
</div>
<script type="text/javascript"> --> this one is added by me manually
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
</script>
<div>
<input id="__EVENTTARGET" name="__EVENTTARGET" type="hidden" value=
"" /> <input id="__EVENTARGUMENT" name="__EVENTARGUMENT" type=
"hidden" value="" /> /// sOME CODE HERE
</div>
--> this one is added by me manually
</form>
</body>
</html>
Now, if i remove the _doPostBack added by me, gridview paging works. BUT when i have only 1 page in gridview, my event in jquery dialog does not work because it cant find _doPostBack.
ANSWER:
I have removed the _doPostBack() added by me and instead added this on my Page_Load() which adds a _doPostBack() even if there are no asp.net controls which requires this method.
ClientScript.GetPostBackEventReference(this, string.Empty);
BIG THANKS TO #Tim Schmelter for pointing to that LINK
I've had a similar problem, when trying to popup a dialog confirming a record deletion. This is the code I've used (jQuery UI dialog) and it works perfectly.
Don't add a new doPostBack. Instead, try to follow this idea. You can adapt it to fit your requirements:
// When the user tries to delete a record, show a confirmation.
$(".confirmationButton").click(function(e) {
// Stop the PostBack
e.preventDefault();
$(".confirmationDialog").dialog("open");
});
$(".confirmationDialog").dialog({
buttons: {
"No": function() {
$(this).dialog("close");
},
"Yes": function() {
$(this).dialog("close");
// User confirmed deletion, so carry on with the PostBack.
eval($("#ctl00_MainContentPlaceHolder_hdnBtnPostBack").val());
}
}
});
Somewhere on your code (when checking the page source), you'll find something like this:
<input id="ctl00_MainContentPlaceHolder_hdnBtnPostBack" type="hidden" value="__doPostBack('ctl00$MainContentPlaceHolder$btnDelete','')" name="ctl00$MainContentPlaceHolder$hdnBtnPostBack">
That's the object you will be using with eval().

Google analytics Code Placing in head tag in master page?

Here is the code in the head of my master page ...
<link rel="stylesheet" type="text/css" href="App_Themes/screen.css" />
<link rel="shortcut icon" href="/images/favicon.ico">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
but when i see it in the browser view source ... it is showing it like this
<link rel="stylesheet" type="text/css" href="App_Themes/screen.css" />
<link rel="shortcut icon" href="/images/favicon.ico">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<link href="App_Themes/Site/style.css" type="text/css" rel="stylesheet" />
You notice there is a theme rendering at the end App_Themes/Site/style.css before the tag ... please tell me how can i fix it ... I need google analytics code before the tag ... but this theme rendering at the end forbids me to achieve my goal ...
I am going to guess you're using ASP.Net Themes?
ASP.Net renders your Theme and adds the style to the page.
Your best place to put the Google code is at the bottom of the page just before the </body> tag.
Google in fact recommends that it go just before the closing body tag, as documented here after the standard setup snippet
https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingOverview

Facebook Like - title and description not working

I have created one test page in my jboss-web.deployer\ROOT.war named test.html.
I have added facebook like button and OG meta tags. When i click on like, title and description is not shared on facebook. Even i am unable to see on popup, when i click on like button. Please help....
Please find below code:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:og="http://ogp.me/ns#"
xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<title>The Rock (1996)</title>
<meta property="og:title" content="The Rock"/>
<meta property="og:type" content="movie"/>
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/"/>
<meta property="og:image" content="http://ia.media-imdb.com/rock.jpg"/>
<meta property="og:site_name" content="IMDb"/>
<meta property="fb:admins" content="USER_ID"/>
<meta property="og:description"
content="A group of U.S. Marines, under command of
a renegade general, take over Alcatraz and
threaten San Francisco Bay with biological
weapons."/>
</head>
<body>
<!-- AddThis Button BEGIN -->
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<fb:like href="href="http://157.241.56.242:8080/Test5.html" width="450" height="80"/>
<!-- AddThis Button END -->
</body>
</html>
You don't need to add a XML namespace, but a prefix instead. The following is token from http://ogp.me/ :
<html prefix="og: http://ogp.me/ns#">

Blank page for jquery.SPServices that list a sharepoint List

I have a SharePoint List that I wish to view it on a custom aspx file.
The SharePoint List is named - "AM_Code"
Inside the List, there are multiple columns but I just want those rows with the column 'Title' that is not null.
The data will then be displayed on the screen.
The code as follows:
<%# Page Language="C#" %>
<html dir="ltr">
<head runat="server">
<META name="WebPartPageExpansion" content="full">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Testing JQuery with Sharepoint List</title>
</head>
<body>
<form id="form1" runat="server">
</form>
<script type="text/javascript" language="javascript" src="jquery-1.6.2.min.js"></script>
<script type="text/javascript" language="javascript" src="jquery.SPServices-0.6.2.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$().SPServices({
operation: "GetListItems",
async: false,
listName: "AM_Code",
CAMLViewFields: "<Query><Where><IsNotNull><FieldRef Name="Title" /></IsNotNull></Where><OrderBy><FieldRef Name="Title" Ascending="True" /></OrderBy></Query>",
completefunc: function (xData, Status) {
$(xData.responseXML).find("[nodeName='z:row']").each(function() {
var liHtml = "<li>" + $(this).attr("ows_Title") + "</li>";
$("#tasksUL").append(liHtml);
});
}
});
});
</script>
<ul id="tasksUL"/>
</body>
</html>
However nothing was being displayed. Please advise if I have miss anything.
CAMLViewFields: "<Query><Where><IsNotNull><FieldRef Name="Title" /></IsNotNull></Where><OrderBy><FieldRef Name="Title" Ascending="True" /></OrderBy></Query>",
this doesn't seem right to me
Actually I found my own answer.
The CAMLViewFields contain the following in order to work:
"<Query><Where><IsNotNull><FieldRef Name='Title' /></IsNotNull></Where><OrderBy><FieldRef Name='Title' Ascending="True" /></OrderBy></Query>",
Hope it help anyone who is also looking for such solution.

Google analytics not finding tracking script on asp.net site

I have this code in my master page in the head section:
<head runat="server">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta name="google-site-verification" content="830gFtORfJaVYXiLQ6EVfCNoiMW3zyn2DVS7L1zbr20" />
<title></title>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
</asp:ContentPlaceHolder>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-23254350-2']);
_gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script'); ga.type = 'text/javascript';
ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' :
'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
The problem is that google analytics is not seeing the tracking script. Any ideas?
I usually find that the tracking status updates pretty quickly after a page has been viewed and the tracking beacon has been sent.
You should go to the homepage of the site where this is installed and check that the JavaScript code is present in the page source in case the asp code has removed it somehow.
If it's there then you should use something like the Firefox Live HTTP Headers addon check that a request for an image called __utm.gif is being made to Google Analytics.
If that's all OK but the status is still not updated you could try checking that you've entered the correct account number into the tracking code.

Resources