ScriptManager.ScriptResourceMapping Egenskap

Definition

Hämtar ett ScriptResourceMapping objekt.

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

Egenskapsvärde

Ett ScriptResourceMapping objekt.

Exempel

I följande exempel visas hur du lägger till ett ScriptResourceDefinition objekt som kan refereras till av ett ScriptManager objekt. Lägg till följande kod i filen Global.asax i händelsen 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)

Lägg till följande markering i elementet form och före element eller kod som använder jQuery-skript i pålägget för en ASP.NET Web Forms-sida (.aspx fil).

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

Kommentarer

Den statiska ScriptResourceMapping egenskapen returnerar ett ScriptResourceMapping objekt som kan innehålla en samling mappningar som representerar platsen för skriptresursen (omdirigering av skript). Den här samlingen av mappningar kan mappas baserat på namn eller namn/sammansättningspar, och den kan peka på ett ScriptResourceDefinition objekt.

Gäller för