ClientScriptManager.RegisterExpandoAttribute Método
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Registra un par nombre-valor como atributo personalizado (expando) del control especificado.
Sobrecargas
| Nombre | Description |
|---|---|
| RegisterExpandoAttribute(String, String, String) |
Registra un par nombre-valor como atributo personalizado (expando) del control especificado según un identificador de control, un nombre de atributo y un valor de atributo. |
| RegisterExpandoAttribute(String, String, String, Boolean) |
Registra un par nombre-valor como atributo personalizado (expando) del control especificado dado un identificador de control, un nombre de atributo, un valor de atributo y un valor booleano que indica si se va a codificar el valor del atributo. |
RegisterExpandoAttribute(String, String, String)
Registra un par nombre-valor como atributo personalizado (expando) del control especificado según un identificador de control, un nombre de atributo y un valor de atributo.
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)
Parámetros
- attributeName
- String
Nombre del atributo personalizado que se va a registrar.
- attributeValue
- String
Valor del atributo personalizado.
Comentarios
El RegisterExpandoAttribute método registra un par nombre-valor como un atributo personalizado (expando) en el especificado Control. El atributo expando se establece dinámicamente desde JavaScript para conservar la compatibilidad XHTML para el marcado del control representado. Las comillas y barras diagonales inversas en los valores del atributo personalizado (expando) se escapan. Si no desea escapar las comillas y barras diagonales inversas, llame al RegisterExpandoAttribute método de sobrecarga y establezca el encode parámetro falseen .
Si no se encuentra el atributo expando o no se encuentra el control para agregar el atributo expando a , el script de cliente todavía se emite, pero no afectará al control.
Consulte también
Se aplica a
RegisterExpandoAttribute(String, String, String, Boolean)
Registra un par nombre-valor como atributo personalizado (expando) del control especificado dado un identificador de control, un nombre de atributo, un valor de atributo y un valor booleano que indica si se va a codificar el valor del atributo.
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)
Parámetros
- attributeName
- String
Nombre del atributo personalizado que se va a registrar.
- attributeValue
- String
Valor del atributo personalizado.
- encode
- Boolean
Valor booleano que indica si se va a codificar el atributo personalizado que se va a registrar.
Ejemplos
En el ejemplo de código siguiente se muestra cómo usar el RegisterExpandoAttribute método de la ClientScriptManager clase . El script de cliente de la página representada establece el title atributo de un <span> elemento.
<%@ 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>
Comentarios
El RegisterExpandoAttribute método registra un par nombre-valor como un atributo personalizado (expando) en el especificado Control. El atributo expando se establece dinámicamente desde JavaScript para conservar la compatibilidad XHTML para el marcado del control representado. Establezca el parámetro true en si necesita escape entre comillas y barras diagonales inversas en el encode valor del atributo expando.
Si no se encuentra el atributo expando o no se encuentra el control para agregar el atributo expando a , el script de cliente todavía se emite, pero no afectará al control.