Преглед на файлове

Implemented ScriptManager.AsyncPostBackErrorMessage property

svn path=/trunk/mcs/; revision=82077
Igor Zelmanovich преди 18 години
родител
ревизия
444f1204f4

+ 4 - 3
mcs/class/System.Web.Extensions/System.Web.Handlers/ScriptModule.cs

@@ -78,18 +78,19 @@ namespace System.Web.Handlers
 			HttpApplication app = (HttpApplication) sender;
 			HttpContext context = app.Context;
 			if (context.Request.Headers ["X-MicrosoftAjax"] == "Delta=true") {
+				ScriptManager sm = ScriptManager.GetCurrent ((Page) context.CurrentHandler);
 				if (context.Response.StatusCode == 302) {
 					context.Response.StatusCode = 200;
 					context.Response.ClearContent ();
-					if (context.Error == null || ScriptManager.GetCurrent ((Page) context.CurrentHandler).AllowCustomErrorsRedirect)
+					if (context.Error == null || sm.AllowCustomErrorsRedirect)
 						ScriptManager.WriteCallbackRedirect (context.Response.Output, context.Response.RedirectLocation);
 					else
-						ScriptManager.WriteCallbackException (context.Response.Output, context.Error, false);
+						sm.WriteCallbackException (context.Response.Output, context.Error, false);
 				}
 				else if (context.Error != null) {
 					context.Response.StatusCode = 200;
 					context.Response.ClearContent ();
-					ScriptManager.WriteCallbackException (context.Response.Output, context.Error, true);
+					sm.WriteCallbackException (context.Response.Output, context.Error, true);
 				}
 			}
 		}

+ 10 - 4
mcs/class/System.Web.Extensions/System.Web.UI/ScriptManager.cs

@@ -113,6 +113,7 @@ namespace System.Web.UI
 		bool _enablePageMethods;
 		string _controlIDToFocus;
 		bool _allowCustomErrorsRedirect = true;
+		string _asyncPostBackErrorMessage;
 
 		[DefaultValue (true)]
 		[Category ("Behavior")]
@@ -129,10 +130,12 @@ namespace System.Web.UI
 		[DefaultValue ("")]
 		public string AsyncPostBackErrorMessage {
 			get {
-				throw new NotImplementedException ();
+				if (String.IsNullOrEmpty (_asyncPostBackErrorMessage))
+					return String.Empty;
+				return _asyncPostBackErrorMessage;
 			}
 			set {
-				throw new NotImplementedException ();
+				_asyncPostBackErrorMessage = value;
 			}
 		}
 
@@ -925,9 +928,12 @@ namespace System.Web.UI
 
 		#endregion
 
-		static internal void WriteCallbackException (TextWriter output, Exception ex, bool writeMessage) {
+		internal void WriteCallbackException (TextWriter output, Exception ex, bool writeMessage) {
 			HttpException httpEx = ex as HttpException;
-			WriteCallbackOutput (output, error, httpEx == null ? "500" : httpEx.GetHttpCode ().ToString (), writeMessage ? ex.GetBaseException ().Message : null);
+			string message = AsyncPostBackErrorMessage;
+			if (String.IsNullOrEmpty (message) && writeMessage)
+				message = ex.GetBaseException ().Message;
+			WriteCallbackOutput (output, error, httpEx == null ? "500" : httpEx.GetHttpCode ().ToString (), message);
 		}
 
 		static internal void WriteCallbackRedirect (TextWriter output, string redirectUrl) {