2007-02-05 Igor Zelmanovich <igorz@mainsoft.com>
authorIgor Zelmanovich <igorz@mono-cvs.ximian.com>
Mon, 5 Feb 2007 08:38:16 +0000 (08:38 -0000)
committerIgor Zelmanovich <igorz@mono-cvs.ximian.com>
Mon, 5 Feb 2007 08:38:16 +0000 (08:38 -0000)
* DetailsView.cs:
fixed validation flow.

svn path=/trunk/mcs/; revision=72286

mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
mcs/class/System.Web/System.Web.UI.WebControls/DetailsView.cs

index 1d492aaeb9ff91e71990717abb75674738adfc6f..23d8df7f9f58c480d23c63b1f810ac77f53dc7a7 100644 (file)
@@ -1,3 +1,8 @@
+2007-02-05 Igor Zelmanovich <igorz@mainsoft.com>
+
+       * DetailsView.cs:
+       fixed validation flow.  
+
 2007-02-04 Igor Zelmanovich <igorz@mainsoft.com>
 
        * CustomValidator.cs:
index 0950d3a5b9ad295fe1221a86645cf04c023117ac..917a784d243ae5640e37d099a9f1f3ec1220f0a9 100644 (file)
@@ -1446,15 +1446,21 @@ namespace System.Web.UI.WebControls
                {\r
                        DetailsViewCommandEventArgs args = e as DetailsViewCommandEventArgs;\r
                        if (args != null) {\r
-                               ProcessCommand (args);\r
+                               bool causesValidation = false;\r
+                               IButtonControl button = args.CommandSource as IButtonControl;\r
+                               if (button != null && button.CausesValidation) {\r
+                                       Page.Validate (button.ValidationGroup);\r
+                                       causesValidation = true;\r
+                               }\r
+                               ProcessCommand (args, causesValidation);\r
                                return true;\r
                        }\r
                        return base.OnBubbleEvent (source, e);\r
                }\r
 \r
-               void ProcessCommand (DetailsViewCommandEventArgs args) {\r
+               void ProcessCommand (DetailsViewCommandEventArgs args, bool causesValidation) {\r
                        OnItemCommand (args);\r
-                       ProcessEvent (args.CommandName, args.CommandArgument as string);\r
+                       ProcessEvent (args.CommandName, args.CommandArgument as string, causesValidation);\r
                }\r
 \r
                void IPostBackEventHandler.RaisePostBackEvent (string eventArgument)\r
@@ -1471,10 +1477,10 @@ namespace System.Web.UI.WebControls
                                arg = new CommandEventArgs (eventArgument.Substring (0, i), eventArgument.Substring (i + 1));\r
                        else\r
                                arg = new CommandEventArgs (eventArgument, null);\r
-                       ProcessCommand (new DetailsViewCommandEventArgs (this, arg));\r
+                       ProcessCommand (new DetailsViewCommandEventArgs (this, arg), false);\r
                }\r
-               \r
-               void ProcessEvent (string eventName, string param)\r
+\r
+               void ProcessEvent (string eventName, string param, bool causesValidation)\r
                {\r
                        switch (eventName)\r
                        {\r
@@ -1529,7 +1535,7 @@ namespace System.Web.UI.WebControls
                                break;\r
                                        \r
                        case DataControlCommands.UpdateCommandName:\r
-                               UpdateItem (param, true);\r
+                               UpdateItem (param, causesValidation);\r
                                break;\r
                                        \r
                        case DataControlCommands.CancelCommandName:\r
@@ -1541,7 +1547,7 @@ namespace System.Web.UI.WebControls
                                break;\r
                                        \r
                        case DataControlCommands.InsertCommandName:\r
-                               InsertItem (true);\r
+                               InsertItem (causesValidation);\r
                                break;\r
                        }\r
                }\r
@@ -1598,8 +1604,8 @@ namespace System.Web.UI.WebControls
                \r
                void UpdateItem (string param, bool causesValidation)\r
                {\r
-                       if (causesValidation && Page != null)\r
-                               Page.Validate ();\r
+                       if (causesValidation && Page != null && !Page.IsValid)\r
+                               return;\r
                        \r
                        if (CurrentMode != DetailsViewMode.Edit) throw new HttpException ();\r
 \r
@@ -1638,8 +1644,8 @@ namespace System.Web.UI.WebControls
                \r
                void InsertItem (string param, bool causesValidation)\r
                {\r
-                       if (causesValidation && Page != null)\r
-                               Page.Validate ();\r
+                       if (causesValidation && Page != null && !Page.IsValid)\r
+                               return;\r
                        \r
                        if (CurrentMode != DetailsViewMode.Insert) throw new HttpException ();\r
                        \r