ClientScriptManager.RegisterExpandoAttribute メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
名前と値のペアを、指定したコントロールのカスタム (expando) 属性として登録します。
オーバーロード
| 名前 | 説明 |
|---|---|
| RegisterExpandoAttribute(String, String, String) |
コントロール ID、属性名、および属性値を指定して、指定したコントロールのカスタム (expando) 属性として名前と値のペアを登録します。 |
| RegisterExpandoAttribute(String, String, String, Boolean) |
コントロール ID、属性名、属性値、および属性値をエンコードするかどうかを示すブール値を指定して、指定したコントロールのカスタム (expando) 属性として名前と値のペアを登録します。 |
RegisterExpandoAttribute(String, String, String)
コントロール ID、属性名、および属性値を指定して、指定したコントロールのカスタム (expando) 属性として名前と値のペアを登録します。
public:
void RegisterExpandoAttribute(System::String ^ controlId, System::String ^ attributeName, System::String ^ attributeValue);
public void RegisterExpandoAttribute(string controlId, string attributeName, string attributeValue);
member this.RegisterExpandoAttribute : string * string * string -> unit
Public Sub RegisterExpandoAttribute (controlId As String, attributeName As String, attributeValue As String)
パラメーター
- attributeName
- String
登録するカスタム属性の名前。
- attributeValue
- String
カスタム属性の値。
注釈
RegisterExpandoAttribute メソッドは、名前と値のペアを、指定したControlのカスタム (expando) 属性として登録します。 expando 属性は、レンダリングされたコントロールのマークアップの XHTML 互換性を維持するために、JavaScript から動的に設定されます。 カスタム (expando) 属性の値の引用符と円記号はエスケープされます。 引用符と円記号をエスケープしない場合は、 RegisterExpandoAttribute オーバーロード メソッドを呼び出し、 encode パラメーターを false に設定します。
expando 属性が見つからないか、expando 属性を追加するコントロールが見つからない場合、クライアント スクリプトは出力されますが、コントロールには影響しません。
こちらもご覧ください
適用対象
RegisterExpandoAttribute(String, String, String, Boolean)
コントロール ID、属性名、属性値、および属性値をエンコードするかどうかを示すブール値を指定して、指定したコントロールのカスタム (expando) 属性として名前と値のペアを登録します。
public:
void RegisterExpandoAttribute(System::String ^ controlId, System::String ^ attributeName, System::String ^ attributeValue, bool encode);
public void RegisterExpandoAttribute(string controlId, string attributeName, string attributeValue, bool encode);
member this.RegisterExpandoAttribute : string * string * string * bool -> unit
Public Sub RegisterExpandoAttribute (controlId As String, attributeName As String, attributeValue As String, encode As Boolean)
パラメーター
- attributeName
- String
登録するカスタム属性の名前。
- attributeValue
- String
カスタム属性の値。
- encode
- Boolean
登録するカスタム属性をエンコードするかどうかを示すブール値。
例
次のコード例は、ClientScriptManager クラスの RegisterExpandoAttribute メソッドを使用する方法を示しています。 レンダリングされたページのクライアント スクリプトは、<span>要素のtitle属性を設定します。
<%@ Page Language="C#"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
public void Page_Load(Object sender, EventArgs e)
{
// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = Page.ClientScript;
// Register an expando attribute.
cs.RegisterExpandoAttribute("Message", "title", "New title from client script.", true);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>ClientScriptManager Example</title>
</head>
<body>
<form id="Form1"
runat="server">
<span id="Message"
title="Title to be replaced.">
Place your mouse over this text to see the title.
</span>
</form>
</body>
</html>
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
' Get a ClientScriptManager reference from the Page class.
Dim cs As ClientScriptManager = Page.ClientScript
' Register an expando attribute.
cs.RegisterExpandoAttribute("Message", "title", "New title from client script.", True)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>ClientScriptManager Example</title>
</head>
<body>
<form id="Form1"
runat="server">
<span id="Message"
title="Title to be replaced.">
Place your mouse over this text to see the title.
</span>
</form>
</body>
</html>
注釈
RegisterExpandoAttribute メソッドは、名前と値のペアを、指定したControlのカスタム (expando) 属性として登録します。 expando 属性は、レンダリングされたコントロールのマークアップの XHTML 互換性を維持するために、JavaScript から動的に設定されます。 expando 属性の値で引用符と円記号をエスケープする必要がある場合は、 encode パラメーターを true に設定します。
expando 属性が見つからないか、expando 属性を追加するコントロールが見つからない場合、クライアント スクリプトは出力されますが、コントロールには影響しません。