|
Il presente articolo è stato tradotto automaticamente. Passare il puntatore sulle frasi nell'articolo per visualizzare il testo originale. Ulteriori informazioni.
|
Traduzione
Originale
|
Proprietà SendMailErrorEventArgs.Handled
Spazio dei nomi: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Valore proprietà
Tipo: System.Boolean<%@ Page Language="C#" AutoEventWireup="True" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> void MySendingMail(object sender, MailMessageEventArgs e) { Message1.Text = "Sent mail to you to confirm the password change."; } void MySendMailError(object sender, SendMailErrorEventArgs e) { Message1.Text = "Could not send email to confirm password change."; // The MySamplesSite event source has already been created by an administrator. System.Diagnostics.EventLog myLog = new System.Diagnostics.EventLog(); myLog.Log = "Application"; myLog.Source = "MySamplesSite"; myLog.WriteEntry( "Sending mail via SMTP failed with the following error: " + e.Exception.Message.ToString(), System.Diagnostics.EventLogEntryType.Error); e.Handled = true; } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>ChangePassword including a SendMailError Event</title> </head> <body> <form id="form1" runat="server"> <div style="text-align:center"> <h1>ChangePassword</h1> <asp:LoginView ID="LoginView1" Runat="server" Visible="true"> <LoggedInTemplate> <asp:LoginName ID="LoginName1" Runat="server" FormatString="You are logged in as {0}." /> <br /> </LoggedInTemplate> <AnonymousTemplate> You are not logged in </AnonymousTemplate> </asp:LoginView><br /> <asp:ChangePassword ID="ChangePassword1" Runat="server" BorderStyle="Solid" BorderWidth="1" CancelDestinationPageUrl="~/Default.aspx" DisplayUserName="true" OnSendingMail="MySendingMail" OnSendMailError="MySendMailError" ContinueDestinationPageUrl="~/Default.aspx" > <MailDefinition BodyFileName="~\MailFiles\ChangePasswordMail.htm" Subject="Activity information for you"> <EmbeddedObjects> <asp:EmbeddedMailObject Name="LoginGif" Path="~\MailFiles\Login.gif" /> <asp:EmbeddedMailObject Name="PrivacyNoticeTxt" Path="~\MailFiles\PrivacyNotice.txt" /> </EmbeddedObjects> </MailDefinition> </asp:ChangePassword><br /> <asp:Label ID="Message1" Runat="server" ForeColor="Red" /><br /> <asp:HyperLink ID="HyperLink1" Runat="server" NavigateUrl="~/Default.aspx"> Home </asp:HyperLink> </div> </form> </body> </html>
#region Using directives using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; #endregion namespace CreateEventSource { class Program { static void Main(string[] args) { try { // Create the source, if it does not already exist. if (!EventLog.SourceExists("MySamplesSite")) { EventLog.CreateEventSource("MySamplesSite", "Application"); Console.WriteLine("Creating Event Source"); } // Create an EventLog instance and assign its source. EventLog myLog = new EventLog(); myLog.Source = "MySamplesSite"; // Write an informational entry to the event log. myLog.WriteEntry("Testing writing to event log."); Console.WriteLine("Message written to event log."); } catch (Exception e) { Console.WriteLine("Exception:"); Console.WriteLine("{0}", e.ToString()); } } } }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (ruoli di base del server non supportati), Windows Server 2008 R2 (ruoli di base del server supportati con SP1 o versione successiva, Itanium non supportato)
.NET Framework non supporta tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema di .NET Framework.