Partager via


ScriptManager.ScriptResourceMapping Propriété

Définition

Obtient un ScriptResourceMapping objet.

public:
 static property System::Web::UI::ScriptResourceMapping ^ ScriptResourceMapping { System::Web::UI::ScriptResourceMapping ^ get(); };
public static System.Web.UI.ScriptResourceMapping ScriptResourceMapping { get; }
static member ScriptResourceMapping : System.Web.UI.ScriptResourceMapping
Public Shared ReadOnly Property ScriptResourceMapping As ScriptResourceMapping

Valeur de propriété

Objet ScriptResourceMapping.

Exemples

Les exemples suivants montrent comment ajouter un ScriptResourceDefinition objet qui peut être référencé par un ScriptManager objet. Ajoutez le code suivant au fichier Global.asax dans l’événement Application_Start .

ScriptResourceDefinition myScriptResDef = new ScriptResourceDefinition();
myScriptResDef.Path = "~/Scripts/jquery-1.4.2.min.js";
myScriptResDef.DebugPath = "~/Scripts/jquery-1.4.2.js";
myScriptResDef.CdnPath = "http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.min.js";
myScriptResDef.CdnDebugPath = "http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.js";
ScriptManager.ScriptResourceMapping.AddDefinition("jquery", null, myScriptResDef);
Dim myScriptResDef As New ScriptResourceDefinition()
myScriptResDef.Path = "~/Scripts/jquery-1.4.2.min.js"
myScriptResDef.DebugPath = "~/Scripts/jquery-1.4.2.js"
myScriptResDef.CdnPath = "http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.min.js"
myScriptResDef.CdnDebugPath = "http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.js"
ScriptManager.ScriptResourceMapping.AddDefinition("jquery", Nothing, myScriptResDef)

Dans le balisage d’une page Web Forms ASP.NET (fichier .aspx), ajoutez le balisage suivant à l’intérieur de l’élément form et avant tout élément ou code qui utilise le script jQuery.

<asp:ScriptManager ID="sm1" runat="server">
  <Scripts>
    <asp:ScriptReference Name="jquery"/>
  </Scripts>
</asp:ScriptManager>

Remarques

La propriété statique ScriptResourceMapping retourne un ScriptResourceMapping objet qui peut contenir une collection de mappages qui représentent l’emplacement de la ressource de script (redirection de script). Cette collection de mappages peut être mappée en fonction des noms ou des paires nom/assembly, et peut pointer vers un ScriptResourceDefinition objet.

S’applique à