2006-10-24 Igor Zelmanovich <igorz@mainsoft.com>
authorIgor Zelmanovich <igorz@mono-cvs.ximian.com>
Tue, 24 Oct 2006 12:42:23 +0000 (12:42 -0000)
committerIgor Zelmanovich <igorz@mono-cvs.ximian.com>
Tue, 24 Oct 2006 12:42:23 +0000 (12:42 -0000)
* CommandField.cs: fixed:
considers CaseValidation, ValidationGroup, ButtonType.
* DataControlButton.cs: refactoring:

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

mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
mcs/class/System.Web/System.Web.UI.WebControls/CommandField.cs
mcs/class/System.Web/System.Web.UI.WebControls/DataControlButton.cs
mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
mcs/class/System.Web/Test/System.Web.UI.WebControls/GridViewTest.cs

index b79824bede25465a3981957cd99f9214c46a3acb..e16bc0e1fc1e94e8f181fc24cdaa88088bd64a8f 100644 (file)
@@ -1,3 +1,9 @@
+2006-10-24 Igor Zelmanovich <igorz@mainsoft.com>
+
+       * CommandField.cs: fixed: 
+       considers CaseValidation, ValidationGroup, ButtonType.
+       * DataControlButton.cs: refactoring:
+
 2006-10-24 Igor Zelmanovich <igorz@mainsoft.com>
 
        * DetailsView.cs: implemented: GetCallbackScript method.
index 13ae436be3f8213b8529268b08e333f63958f66d..104ce446487482d61a5b4e9738d1283d7c162115 100644 (file)
@@ -317,7 +317,14 @@ namespace System.Web.UI.WebControls {
                DataControlButton CreateButton (string text, string image, string command, string arg)\r
                {\r
                        DataControlButton c = new DataControlButton (Control, text, image, command, arg, false);\r
-                       //c.CausesValidation = CausesValidation;\r
+                       c.ButtonType = ButtonType;\r
+                       if (CausesValidation) {\r
+                               if (command == DataControlCommands.UpdateCommandName || command == DataControlCommands.InsertCommandName) {\r
+                                       c.Container = null;\r
+                                       c.CausesValidation = true;\r
+                                       c.ValidationGroup = ValidationGroup;\r
+                               }\r
+                       }\r
                        return c;\r
                }\r
                \r
index e28abfc74cc398374834b483d04bfebcfc20108b..07acff98302f4f7bd95c8232e5c773af7305434e 100644 (file)
@@ -57,6 +57,11 @@ namespace System.Web.UI.WebControls
                        AllowCallback = allowCallback;
                }
                
+               public Control Container {
+                       get { return container; }
+                       set { container = value; }
+               }
+
                public string ImageUrl {
                        get {
                                object o = ViewState["iu"];
@@ -100,19 +105,17 @@ namespace System.Web.UI.WebControls
                        {
                                string postScript = null;
                                string callScript = null;
-                               
+                               PostBackOptions ops = null;
+
                                IPostBackContainer pcner = container as IPostBackContainer;
                                if (pcner != null) {
-                                       PostBackOptions ops = pcner.GetPostBackOptions (this);
-                                       postScript = container.Page.ClientScript.GetPostBackEventReference (ops);
-                               } else
-                                       postScript = Page.ClientScript.GetPostBackEventReference (this, "");
-
-                               if (CausesValidation && Page.Validators.Count > 0) {
-                                       // TOSHOK: review if this is the correct usage of the "fresh" client side stuff
-                                       ClientScriptManager csm = new ClientScriptManager (Page);
-                                       postScript = csm.GetClientValidationEvent () + postScript;
+                                       ops = pcner.GetPostBackOptions (this);
+                                       ops.RequiresJavaScriptProtocol = ButtonType == ButtonType.Link;
                                }
+                               else
+                                       ops = GetPostBackOptions ();
+
+                               postScript = Page.ClientScript.GetPostBackEventReference (ops);
                                
                                if (AllowCallback) {
                                        ICallbackContainer ccner = container as ICallbackContainer;
@@ -138,10 +141,8 @@ namespace System.Web.UI.WebControls
                                if (ButtonType == ButtonType.Link) {
                                        if (callScript != null) {
                                                writer.AddAttribute (HtmlTextWriterAttribute.Onclick, callScript);
-                                               writer.AddAttribute (HtmlTextWriterAttribute.Href, "javascript:");
                                        }
-                                       else
-                                               writer.AddAttribute (HtmlTextWriterAttribute.Href, "javascript:" + postScript);
+                                       writer.AddAttribute (HtmlTextWriterAttribute.Href, postScript);
                                        writer.RenderBeginTag (HtmlTextWriterTag.A);
                                        writer.Write (Text);
                                        writer.RenderEndTag ();
@@ -152,7 +153,7 @@ namespace System.Web.UI.WebControls
                                        else
                                                writer.AddAttribute (HtmlTextWriterAttribute.Onclick, postScript);
 
-                                       writer.AddAttribute (HtmlTextWriterAttribute.Type, "submit");
+                                       writer.AddAttribute (HtmlTextWriterAttribute.Type, "button");
                                        writer.AddAttribute (HtmlTextWriterAttribute.Name, ClientID);
                                        writer.AddAttribute (HtmlTextWriterAttribute.Value, Text);
                                        writer.RenderBeginTag (HtmlTextWriterTag.Input);
@@ -179,6 +180,18 @@ namespace System.Web.UI.WebControls
                                }
                        }
                }
+               
+               protected override PostBackOptions GetPostBackOptions () {
+                       PostBackOptions options = new PostBackOptions (this);
+                       options.Argument = "";
+                       options.RequiresJavaScriptProtocol = ButtonType == ButtonType.Link;
+                       options.ClientSubmit = true;
+                       options.PerformValidation = CausesValidation && Page != null && Page.AreValidatorsUplevel (ValidationGroup);
+                       if (options.PerformValidation)
+                               options.ValidationGroup = ValidationGroup;
+
+                       return options;
+               }
 
                private void EnsureForeColor () {
                        if (ForeColor != Color.Empty)
index f77bc4d425b105e1b38ecc9b0ad081e7ad40aca2..b2618e71b21933e6923c1cbdfcc47ae7e608bf49 100644 (file)
@@ -1,3 +1,7 @@
+2006-10-24 Igor Zelmanovich <igorz@mainsoft.com>
+
+       * GridViewTest.cs: removed NotWorking attributes
+                       
 2006-10-23 Igor Zelmanovich <igorz@mainsoft.com>
 
        * FormViewTest.cs: new tests were added
index 425814ffa47b9bd9ffc151039a423ce963c093b5..d0c2e2193149fc2ee2a53604c94756fa286979bc 100644 (file)
@@ -506,7 +506,6 @@ namespace MonoTests.System.Web.UI.WebControls
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void GridView_Sort_and_DataSourceSelectArguments () {
                        DataSourceView view;
                        DataSourceSelectArguments arg;
@@ -552,7 +551,6 @@ namespace MonoTests.System.Web.UI.WebControls
                // contains the arguments passed to the data source. In this implementation, 
                // the DataSourceSelectArguments object contains the arguments for paging operations.
                [Test]
-               [Category ("NotWorking")]
                public void GridView_CreateDataSourceSelectArguments () {
                        DataSourceView view;
                        Page p = new Page ();
@@ -781,7 +779,6 @@ namespace MonoTests.System.Web.UI.WebControls
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void GridView_GetCallbackResult()
                {
                        Page page = new Page ();
@@ -1194,7 +1191,6 @@ namespace MonoTests.System.Web.UI.WebControls
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void GridView_PrepareControlHierarchy ()
                {
                        PokerGridView gv = new PokerGridView ();
@@ -1508,7 +1504,6 @@ namespace MonoTests.System.Web.UI.WebControls
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void GridView_RenderingButtonField ()
                {
                        string RenderedPageHtml = new WebTest (PageInvoker.CreateOnLoad (RenderingButtonField)).Run ();
@@ -2319,3 +2314,4 @@ namespace MonoTests.System.Web.UI.WebControls
 
 
 
+