2
約20の製品一覧を表示するASP.NET 4.0ホームページがあります。各商品リストには、次の形式のURLが表示されます。/DisplayProduct.aspx?ProdID=X
ASP.NETユーザーコントロールのGoogle Plus
各商品リストの前にGoogleプラスとリツイートの数が表示されます。どのようにして最適な方法で最適化し、ページの読み込み速度に影響を与えずに行えますか?どのようなスクリプトを使用する必要がありますか?
ここでは、上記のは、あなたがその製品を指す別のURLで、製品ごとに繰り返して欲しいものであること
<!-- Place this tag where you want the +1 button to render -->
<g:plusone size="small" annotation="none" href="http://www.yourwebsite.com/DisplayProduct.aspx?ProdID=<%# Eval("Name") %>"></g:plusone>
ような何かをしなければならないコード
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ProductListing.ascx.cs" Inherits="Controls.ProductListing" %>
<asp:GridView ID="gvProducts" runat="server" AllowPaging="True" AutoGenerateColumns="False"
DataKeyNames="ID" DataSourceID="objProds" PageSize="10" ShowHeader="False"
OnRowDataBound="gvProducts_RowDataBound" OnRowCommand="gvProducts_RowCommand"
>
<Columns>
<asp:TemplateField HeaderText="Product List">
<HeaderStyle />
<ItemTemplate>
<div class="plist">
<table cellpadding="0" cellspacing="0" style="width: 100%;">
<tr><td>
<div class="productname">
<asp:HyperLink runat="server" ID="hypName" Text='<%# Eval("Name") %>'
NavigateUrl='<%# "~/DisplayProduct.aspx?ID=" + Eval("ProdID") %>'/>
</div>
</td> </tr>
</table>
<div class="productdesc">
<b>Description: </b>
<asp:Literal runat="server" ID="lblDesc" Text='<%# Eval("Description") %>' />
</div>
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
このスクリプトをユーザーコントロールに追加する必要がありますか?それはどこに合うのですか?さらに、製品のURLは動的に作成されています。したがって、> g:plusoneスクリプトで指定することはできます – CuriousDev
リンクにNavigateUrlを設定するのと同じ方法でhrefを割り当てる必要があります。 –
g +ボタンが他の場所にある場合は、このスクリプトをページの最下部に置いておきます。このスクリプトは、ページの下部に配置するのが理想的です(ブラウザはコンテンツを最初に表示してからスクリプトに注意してください)。 –