AttributeCollection.AddAttributes メソッド
アセンブリ: System.Web (system.web.dll 内)


このメソッドはサーバー コントロールのすべての属性を HtmlTextWriter オブジェクトにコピーし、次回の RenderBeginTag メソッドの呼び出しで表示されるようにします。
Calendar コントロールや CheckBoxList コントロールなどのサロゲート コントロールを直接表示すると、サロゲート コントロールに表示されるサーバー コントロールのパフォーマンスが向上する可能性があります。直接表示は、サロゲート コントロールを通じた表示よりも高速です。サロゲートでは、すべての子コントロール属性をサロゲートにコピーし、コピー時に 1 回表示する必要があるからです。

新しい属性を Button サーバー コントロール myButton と TextBox サーバー コントロール myTextBox に追加し、次にこれらの属性をカスタム HtmlTextWriter に追加し、これらの属性をコントロールの各出力ストリームに書き込む例を次に示します。
myButton.Attributes.Clear() myTextBox.Attributes.Clear() myButton.Attributes("onClick") = "javascript:alert('Visiting msn.com');" myTextBox.Attributes("name") = "MyTextBox" myTextBox.Attributes("onBlur") = "javascript:alert('Leaving MyTextBox...');" Dim myHttpResponse As HttpResponse = Response Dim myHtmlTextWriter As New HtmlTextWriter(myHttpResponse.Output) myButton.Attributes.AddAttributes(myHtmlTextWriter) myTextBox.Attributes.AddAttributes(myHtmlTextWriter)
myButton.Attributes.Clear(); myTextBox.Attributes.Clear(); myButton.Attributes["onClick"] = "javascript:alert('Visiting msn.com');"; myTextBox.Attributes["name"] = "MyTextBox"; myTextBox.Attributes["onBlur"] = "javascript:alert('Leaving MyTextBox...');"; HttpResponse myHttpResponse = Response; HtmlTextWriter myHtmlTextWriter = new HtmlTextWriter(myHttpResponse.Output); myButton.Attributes.AddAttributes(myHtmlTextWriter); myTextBox.Attributes.AddAttributes(myHtmlTextWriter);
myButton.get_Attributes().Clear(); myTextBox.get_Attributes().Clear(); myButton.get_Attributes().set_Item("onClick", "javascript:alert('Visiting msn.com');"); myTextBox.get_Attributes().set_Item("name","MyTextBox"); myTextBox.get_Attributes().set_Item("onBlur", "javascript:alert('Leaving MyTextBox...');"); HttpResponse myHttpResponse = get_Response(); HtmlTextWriter myHtmlTextWriter = new HtmlTextWriter(myHttpResponse. get_Output()); myButton.get_Attributes().AddAttributes(myHtmlTextWriter); myTextBox.get_Attributes().AddAttributes(myHtmlTextWriter);

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からAttributeCollection.AddAttributes メソッドを検索する場合は、下記のリンクをクリックしてください。

- AttributeCollection.AddAttributes メソッドのページへのリンク