2012-01-16 63 views
0

我有一个用户控件声明一个asp.net web表单链接控件如下:将Google+旁边ASP.NET超链接

<asp:HyperLink runat="server" ID="lnk" CssClass="title" Text='<%# Eval("PostTitle") %>' 
        NavigateUrl='<%# "~/DisplayPost.aspx?ID=" + Eval("ID") %>'/> 

我要新增一个谷歌+按钮,这一点,并通过动态地将网址导航到Google+按钮。我怎样才能做到这一点?

回答

1

请参阅Google+ button page来执行此操作。一个例子,你会是如下:

<!-- Place this tag where you want the +1 button to render --> 
<g:plusone annotation="inline" href="<%# "~/DisplayPost.aspx?ID=" + Eval("ID") %>"></g:plusone> 

<!-- Place this render call where appropriate --> 
<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> 

也有直接把你的链接后进入的网页上加1按钮的选项。

+0

这不能在用户控件中工作..给出一个iframe错误 – 2012-01-16 04:42:54