更新パネルからのポストバック後にJSファイルを登録しようとしています。私はポストバックの後にAddThis.comを働かそうとしています。 multiview.activeviewindexを1に設定すると動作します。ただし、ビュー1からビュー2に移動すると機能しません。AddThis.com - ScriptManager
ここにプロジェクトのサーバーサイドコードがあります。ここで
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'ScriptManager.RegisterStartupScript(Me, Me.GetType, "Test", "http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d4c6a5604aba88b", False)
ScriptManager.RegisterClientScriptBlock(Me, Me.GetType, "Test1", "http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d4c6a5604aba88b", True)
MultiView1.ActiveViewIndex = 0
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
MultiView1.ActiveViewIndex = 1
End Sub
は、ASPXコードです:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebApplication6._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d4c6a5604aba88b"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
<asp:View ID="View1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Button" />
</asp:View>
<asp:View ID="View2" runat="server">
<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style addthis_32x32_style">
<a class="addthis_button_preferred_1"></a>
<a class="addthis_button_preferred_2"></a>
<a class="addthis_button_preferred_3"></a>
<a class="addthis_button_preferred_4"></a>
<a class="addthis_button_compact"></a>
</div>
<!-- AddThis Button END -->
</asp:View>
</asp:MultiView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
私はのScriptManagerに起動スクリプトを登録しようとしています。
誰でもこの方法を知っていますか?
ありがとうございます!
多分私は誤解していますあなたの意図した結果は何ですか?「View 1からView 2に移行する」と言うと、View2にはAddThisのマークアップがないので、予想通りです.AddThisのボタンを常に表示させようとしていますか?どのビューがアクティブであっても関係なく表示されますか? –
混乱してごめんね。この場合、ビューの名前を使用している場合、ビュー2からビュー1に移動することを意図しています。 AddThis Markupを2番目のビューで表示したいだけです。何かもっと説明できるかどうか教えてください。 – Jeff