|
Cet article a fait l'objet d'une traduction automatique. Déplacez votre pointeur sur les phrases de l'article pour voir la version originale de ce texte. Informations supplémentaires.
|
Traduction
Source
|
ScriptManager, classe
Espace de noms : System.Web.UI
Assembly : System.Web.Extensions (dans System.Web.Extensions.dll)
Le type ScriptManager expose les membres suivants.
| Nom | Description | |
|---|---|---|
![]() | Adapter | |
![]() | AjaxFrameworkAssembly | |
![]() | AjaxFrameworkMode | |
![]() | AllowCustomErrorsRedirect | |
![]() | AppRelativeTemplateSourceDirectory | |
![]() | AsyncPostBackErrorMessage | |
![]() | AsyncPostBackSourceElementID | |
![]() | AsyncPostBackTimeout | |
![]() | AuthenticationService | |
![]() | BindingContainer | Infrastructure. |
![]() | ChildControlsCreated | |
![]() | ClientID | |
![]() | ClientIDMode | |
![]() | ClientIDSeparator | |
![]() | ClientNavigateHandler | |
![]() | CompositeScript | |
![]() | Context | |
![]() | Controls | |
![]() | DataItemContainer | |
![]() | DataKeysContainer | |
![]() | DesignMode | |
![]() | EmptyPageUrl | |
![]() | EnableCdn | |
![]() | EnableCdnFallback | |
![]() | EnableHistory | |
![]() | EnablePageMethods | |
![]() | EnablePartialRendering | |
![]() | EnableScriptGlobalization | |
![]() | EnableScriptLocalization | |
![]() | EnableSecureHistoryState | |
![]() | EnableTheming | |
![]() | EnableViewState | |
![]() | Events | |
![]() | HasChildViewState | |
![]() | ID | |
![]() | IdSeparator | Infrastructure. |
![]() | IsChildControlStateCleared | |
![]() | IsDebuggingEnabled | |
![]() | IsInAsyncPostBack | |
![]() | IsNavigating | |
![]() | IsTrackingViewState | |
![]() | IsViewStateEnabled | |
![]() | LoadScriptsBeforeUI | |
![]() | LoadViewStateByID | |
![]() | NamingContainer | |
![]() | Page | |
![]() | Parent | |
![]() | ProfileService | |
![]() | RenderingCompatibility | |
![]() | RoleService | |
![]() | ScriptMode | |
![]() | ScriptPath | Obsolète. |
![]() ![]() | ScriptResourceMapping | |
![]() | Scripts | |
![]() | Services | |
![]() | Site | |
![]() | SkinID | |
![]() | SupportsPartialRendering | |
![]() | TemplateControl | |
![]() | TemplateSourceDirectory | |
![]() | UniqueID | |
![]() | ValidateRequestMode | |
![]() | ViewState | |
![]() | ViewStateIgnoresCase | |
![]() | ViewStateMode | |
![]() | Visible |
| Nom | Description | |
|---|---|---|
![]() | AddedControl | |
![]() | AddHistoryPoint(NameValueCollection, String) | |
![]() | AddHistoryPoint(String, String) | |
![]() | AddHistoryPoint(String, String, String) | |
![]() | AddParsedSubObject | |
![]() | ApplyStyleSheetSkin | |
![]() | BeginRenderTracing | |
![]() | BuildProfileTree | Infrastructure. |
![]() | ClearCachedClientID | Infrastructure. |
![]() | ClearChildControlState | |
![]() | ClearChildState | |
![]() | ClearChildViewState | |
![]() | ClearEffectiveClientIDMode | Infrastructure. |
![]() | CreateChildControls | |
![]() | CreateControlCollection | |
![]() | DataBind() | |
![]() | DataBind(Boolean) | |
![]() | DataBindChildren | |
![]() | Dispose | |
![]() | EndRenderTracing | |
![]() | EnsureChildControls | |
![]() | EnsureID | |
![]() | Equals(Object) | |
![]() | Finalize | |
![]() | FindControl(String) | |
![]() | FindControl(String, Int32) | Infrastructure. |
![]() | Focus | |
![]() ![]() | GetCurrent | |
![]() | GetDesignModeState | Infrastructure. |
![]() | GetHashCode | |
![]() | GetRegisteredArrayDeclarations | |
![]() | GetRegisteredClientScriptBlocks | |
![]() | GetRegisteredDisposeScripts | |
![]() | GetRegisteredExpandoAttributes | |
![]() | GetRegisteredHiddenFields | |
![]() | GetRegisteredOnSubmitStatements | |
![]() | GetRegisteredStartupScripts | |
![]() | GetRouteUrl(Object) | |
![]() | GetRouteUrl(RouteValueDictionary) | |
![]() | GetRouteUrl(String, Object) | |
![]() | GetRouteUrl(String, RouteValueDictionary) | |
![]() | GetStateString | |
![]() | GetType | |
![]() | GetUniqueIDRelativeTo | |
![]() | HasControls | |
![]() | HasEvents | |
![]() | IsLiteralContent | Infrastructure. |
![]() | LoadControlState | |
![]() | LoadPostData | |
![]() | LoadViewState | |
![]() | MapPathSecure | |
![]() | MemberwiseClone | |
![]() | OnAsyncPostBackError | |
![]() | OnBubbleEvent | |
![]() | OnDataBinding | |
![]() | OnInit | |
![]() | OnLoad | |
![]() | OnPreRender | |
![]() | OnResolveCompositeScriptReference | |
![]() | OnResolveScriptReference | |
![]() | OnUnload | |
![]() | OpenFile | |
![]() | RaiseBubbleEvent | |
![]() | RaisePostBackEvent | |
![]() | RaisePostDataChangedEvent | |
![]() ![]() | RegisterArrayDeclaration(Control, String, String) | |
![]() ![]() | RegisterArrayDeclaration(Page, String, String) | |
![]() | RegisterAsyncPostBackControl | |
![]() ![]() | RegisterClientScriptBlock(Control, Type, String, String, Boolean) | |
![]() ![]() | RegisterClientScriptBlock(Page, Type, String, String, Boolean) | |
![]() ![]() | RegisterClientScriptInclude(Control, Type, String, String) | |
![]() ![]() | RegisterClientScriptInclude(Page, Type, String, String) | |
![]() ![]() | RegisterClientScriptResource(Control, Type, String) | |
![]() ![]() | RegisterClientScriptResource(Page, Type, String) | |
![]() | RegisterDataItem(Control, String) | |
![]() | RegisterDataItem(Control, String, Boolean) | |
![]() | RegisterDispose | |
![]() ![]() | RegisterExpandoAttribute | |
![]() | RegisterExtenderControl<TExtenderControl> | |
![]() ![]() | RegisterHiddenField(Control, String, String) | |
![]() ![]() | RegisterHiddenField(Page, String, String) | |
![]() ![]() | RegisterNamedClientScriptResource(Control, String) | |
![]() ![]() | RegisterNamedClientScriptResource(Page, String) | |
![]() ![]() | RegisterOnSubmitStatement(Control, Type, String, String) | |
![]() ![]() | RegisterOnSubmitStatement(Page, Type, String, String) | |
![]() | RegisterPostBackControl | |
![]() | RegisterScriptControl<TScriptControl> | |
![]() | RegisterScriptDescriptors(IExtenderControl) | |
![]() | RegisterScriptDescriptors(IScriptControl) | |
![]() ![]() | RegisterStartupScript(Control, Type, String, String, Boolean) | |
![]() ![]() | RegisterStartupScript(Page, Type, String, String, Boolean) | |
![]() | RemovedControl | |
![]() | Render | |
![]() | RenderChildren | |
![]() | RenderControl(HtmlTextWriter) | |
![]() | RenderControl(HtmlTextWriter, ControlAdapter) | |
![]() | ResolveAdapter | |
![]() | ResolveClientUrl | |
![]() | ResolveUrl | |
![]() | SaveControlState | |
![]() | SaveViewState | |
![]() | SetDesignModeState | |
![]() | SetFocus(Control) | |
![]() | SetFocus(String) | |
![]() | SetRenderMethodDelegate | Infrastructure. |
![]() | SetTraceData(Object, Object) | |
![]() | SetTraceData(Object, Object, Object) | |
![]() | ToString | |
![]() | TrackViewState |
| Nom | Description | |
|---|---|---|
![]() | AsyncPostBackError | |
![]() | DataBinding | |
![]() | Disposed | |
![]() | Init | |
![]() | Load | |
![]() | Navigate | |
![]() | PreRender | |
![]() | ResolveCompositeScriptReference | |
![]() | ResolveScriptReference | |
![]() | Unload |
| Nom | Description | |
|---|---|---|
![]() | FindDataSourceControl | |
![]() | FindFieldTemplate | |
![]() | FindMetaTable |
Introduction
Inscrire le script qui est compatible avec des mises à jour de pages partielles. Pour gérer les dépendances entre votre script et la bibliothèque principale, tout script inscrit est chargé après le script Microsoft Ajax Library. Spécifier si les scripts de version Release ou debug sont envoyés au navigateur. Fournir l'accès aux méthodes de services Web du script en inscrivant les services Web avec le contrôle ScriptManager. Fournir l'accès à l'authentification, au rôle et aux services d'application de profil ASP.NET à partir du script client en inscrivant ces services avec le contrôle ScriptManager. Activer l'affichage spécifique à la culture des fonctions ECMAScript (JavaScript) Date, Nombre et Chaîne dans le navigateur. Accéder aux ressources de localisation pour les fichiers de script incorporés ou pour les fichiers de script autonomes en utilisant la propriété ResourceUICultures du contrôle ScriptReference. Inscrire des contrôles serveur qui implémentent les interfaces IExtenderControl ou IScriptControl avec le contrôle ScriptManager afin que le script requis par les composants clients et les comportements soit restitué.
Rendu de page partiel
La propriété EnablePartialRendering du contrôle ScriptManager doit être true (valeur par défaut). Il doit y avoir au moins un contrôle UpdatePanel sur la page. La propriété SupportsPartialRendering doit être true (valeur par défaut). Si la propriété SupportsPartialRendering n'est pas définie explicitement, sa valeur est basée sur les fonctionnalités de navigateur.
Utilisation du contrôle ScriptManager avec des pages maîtres, des contrôles utilisateur et d'autres composants enfants
Gestion et inscription de scripts
Méthodes d'inscription garantissant que les dépendances de script de Microsoft Ajax Library sont maintenues. Méthodes d'inscription indépendantes de Microsoft Ajax Library, mais compatibles avec les contrôles UpdatePanel. Méthodes d'inscription prenant en charge l'utilisation de contrôles UpdatePanel.
Inscription d'un script dépendant de Microsoft Ajax Library
Inscription de scripts compatibles avec la mise à jour de page partielle
Méthodes d'inscription pour les contrôles UpdatePanel
Références de service Web
Localisation
Fichiers de script incorporés dans un assembly. Le contrôle ScriptManager détermine le fichier de script de culture de secours ou spécifique à la culture à envoyer au navigateur. Pour ce faire, il utilise l'attribut d'assembly NeutralResourcesLanguageAttribute spécifique à la culture, les ressources fournies avec l'assembly et la culture d'interface utilisateur du navigateur (le cas échéant). Fichiers de script autonomes. Le contrôle ScriptManager définit la liste des cultures d'interface utilisateur prises en charge en utilisant la propriété ResourceUICultures de l'objet ScriptReference. En mode débogage. Le contrôle ScriptManager essaie de restituer un fichier de script spécifique à la culture qui contient des informations de débogage. Par exemple, si la page est en mode débogage et si la culture en cours a la valeur en-MX, le contrôle restitue un fichier de script dont le nom est, par exemple, scriptname.en-MX.debug.js, si le fichier existe. Si le fichier n'existe pas, le fichier de débogage pour la culture de secours appropriée est restitué.
Gestion des erreurs
Syntaxe déclarative
<asp:ScriptManager AllowCustomErrorsRedirect="True|False" AsyncPostBackErrorMessage="string" AsyncPostBackTimeout="integer" AuthenticationService-Path="uri" EnablePageMethods="True|False" EnablePartialRendering="True|False" EnableScriptGlobalization="True|False" EnableScriptLocalization="True|False" EnableTheming="True|False" EnableViewState="True|False" ID="string" LoadScriptsBeforeUI="True|False" OnAsyncPostBackError="AsyncPostBackError event handler" OnDataBinding="DataBinding event handler" OnDisposed="Disposed event handler" OnInit="Init event handler" OnLoad="Load event handler" OnPreRender="PreRender event handler" OnResolveScriptReference="ResolveScriptReference event handler" OnUnload="Unload event handler" ProfileService-LoadProperties="string" ProfileService-Path="uri" RoleService-LoadRoles="True|False" RoleService-Path="uri" runat="server" ScriptMode="Auto|Inherit|Debug|Release" ScriptPath="string" SkinID="string" SupportsPartialRendering="True|False" Visible="True|False" > <AuthenticationService Path="uri" /> <ProfileService LoadProperties="string" Path="uri" /> <RoleService LoadRoles="True|False" Path="uri" /> <Scripts> <asp:ScriptReference Assembly="string" IgnoreScriptPath="True|False" Name="string" NotifyScriptLoaded="True|False" Path="string" ResourceUICultures="string" ScriptMode="Auto|Debug|Inherit|Release" /> </Scripts> <Services> <asp:ServiceReference InlineScript="True|False" Path="string" /> </Services> </asp:ScriptManager>
| Topic | Location |
|---|---|
| Vue d'ensemble du contrôle UpdatePanel | Génération d'applications Web ASP.NET dans Visual Studio |
| Vue d'ensemble du contrôle ScriptManager | Génération d'applications Web ASP.NET dans Visual Studio |
Activation de mises à jour de pages partielles
<%@ 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"> void DropDownSelection_Change(Object sender, EventArgs e) { Calendar1.DayStyle.BackColor = System.Drawing.Color.FromName(ColorList.SelectedItem.Value); } protected void Calendar1_SelectionChanged(object sender, EventArgs e) { SelectedDate.Text = Calendar1.SelectedDate.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>UpdatePanel Example</title> </head> <body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Calendar ID="Calendar1" ShowTitle="True" OnSelectionChanged="Calendar1_SelectionChanged" runat="server" /> <div> Background: <br /> <asp:DropDownList ID="ColorList" AutoPostBack="True" OnSelectedIndexChanged="DropDownSelection_Change" runat="server"> <asp:ListItem Selected="True" Value="White"> White </asp:ListItem> <asp:ListItem Value="Silver"> Silver </asp:ListItem> <asp:ListItem Value="DarkGray"> Dark Gray </asp:ListItem> <asp:ListItem Value="Khaki"> Khaki </asp:ListItem> <asp:ListItem Value="DarkKhaki"> D ark Khaki </asp:ListItem> </asp:DropDownList> </div> <br /> Selected date: <asp:Label ID="SelectedDate" runat="server">None.</asp:Label> </ContentTemplate> </asp:UpdatePanel> <br /> </div> </form> </body> </html>
Gestion des erreurs de mise à jour de page partielle et inscription de script
<%@ 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"> protected void Button1_Click(object sender, EventArgs e) { try { int a = Int32.Parse(TextBox1.Text); int b = Int32.Parse(TextBox2.Text); int res = a / b; Label1.Text = res.ToString(); } catch (Exception ex) { if (TextBox1.Text.Length > 0 && TextBox2.Text.Length > 0) { ex.Data["ExtraInfo"] = " You can't divide " + TextBox1.Text + " by " + TextBox2.Text + "."; } throw ex; } } protected void ScriptManager1_AsyncPostBackError(object sender, AsyncPostBackErrorEventArgs e) { if (e.Exception.Data["ExtraInfo"] != null) { ScriptManager1.AsyncPostBackErrorMessage = e.Exception.Message + e.Exception.Data["ExtraInfo"].ToString(); } else { ScriptManager1.AsyncPostBackErrorMessage = "An unspecified error occurred."; } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>UpdatePanel Error Handling Example</title> <style type="text/css"> #UpdatePanel1 { width: 200px; height: 50px; border: solid 1px gray; } #AlertDiv{ left: 40%; top: 40%; position: absolute; width: 200px; padding: 12px; border: #000000 1px solid; background-color: white; text-align: left; visibility: hidden; z-index: 99; } #AlertButtons{ position: absolute; right: 5%; bottom: 5%; } </style> </head> <body id="bodytag"> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" OnAsyncPostBackError="ScriptManager1_AsyncPostBackError" runat="server" > <Scripts> <asp:ScriptReference Path="ErrorHandling.js" /> </Scripts> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:TextBox ID="TextBox1" runat="server" Width="39px"></asp:TextBox> / <asp:TextBox ID="TextBox2" runat="server" Width="39px"></asp:TextBox> = <asp:Label ID="Label1" runat="server"></asp:Label><br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="calculate" /> </ContentTemplate> </asp:UpdatePanel> <div id="AlertDiv"> <div id="AlertMessage"> </div> <br /> <div id="AlertButtons"> <input id="OKButton" type="button" value="OK" runat="server" onclick="ClearErrorState()" /> </div> </div> </div> </form> </body> </html>
Globalisation de la date et de l'heure affichées dans le navigateur
<%@ Page Language="C#" Culture="auto" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>Globalization Example</title> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" EnableScriptGlobalization="true" runat="server"> </asp:ScriptManager> <script type="text/javascript"> function pageLoad() { Sys.UI.DomEvent.addHandler($get("Button1"), "click", formatDate); } function formatDate() { var d = new Date(); try { $get('Label1').innerHTML = d.localeFormat("dddd, dd MMMM yyyy HH:mm:ss"); } catch(e) { alert("Error:" + e.message); } } </script> <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="False" UpdateMode="Conditional"> <ContentTemplate> <asp:Panel ID="Panel1" runat="server" GroupingText="Update Panel"> <asp:Button ID="Button1" runat="server" Text="Display Date" /> <br /> <asp:Label ID="Label1" runat="server"></asp:Label> </asp:Panel> </ContentTemplate> </asp:UpdatePanel> </form> </body> </html>
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (rôle principal du serveur non pris en charge), Windows Server 2008 R2 (rôle principal du serveur pris en charge avec SP1 ou version ultérieure ; Itanium non pris en charge)
Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.

