Author: igorz
Date: 2006-11-27 08:22:55 -0500 (Mon, 27 Nov 2006)
New Revision: 68508

Modified:
   trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog
   trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlForm.cs
   trunk/mcs/class/System.Web/System.Web.UI/ChangeLog
   trunk/mcs/class/System.Web/System.Web.UI/Page.cs
   trunk/mcs/class/System.Web/System.Web.UI/PageLifeCycle.cs
Log:
2006-11-27 Igor Zelmanovich <[EMAIL PROTECTED]>

        * Page.cs: implemented SetFocus methods.
        * PageLifeCycle.cs:     



Modified: trunk/mcs/class/System.Web/System.Web.UI/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI/ChangeLog  2006-11-27 12:52:08 UTC 
(rev 68507)
+++ trunk/mcs/class/System.Web/System.Web.UI/ChangeLog  2006-11-27 13:22:55 UTC 
(rev 68508)
@@ -1,5 +1,10 @@
 2006-11-27 Igor Zelmanovich <[EMAIL PROTECTED]>
 
+       * Page.cs: implemented SetFocus methods.
+       * PageLifeCycle.cs:     
+
+2006-11-27 Igor Zelmanovich <[EMAIL PROTECTED]>
+
        * ClientScriptManager.cs: refactoring:
        extracted method RegisterWebFormClientScript    
 

Modified: trunk/mcs/class/System.Web/System.Web.UI/Page.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI/Page.cs    2006-11-27 12:52:08 UTC 
(rev 68507)
+++ trunk/mcs/class/System.Web/System.Web.UI/Page.cs    2006-11-27 13:22:55 UTC 
(rev 68508)
@@ -75,6 +75,7 @@
        private bool _eventValidation = true;
        private object [] _savedControlState;
        private bool _doLoadPreviousPage;
+       string _focusedControlID;
 #endif
        private bool _viewState = true;
        private bool _viewStateMac;
@@ -1262,6 +1263,7 @@
                Trace.Write ("aspx.page", "End PreRender");
                
 #if NET_2_0
+               _lifeCycle = PageLifeCycle.PreRenderComplete;
                OnPreRenderComplete (EventArgs.Empty);
 #endif
 
@@ -1726,6 +1728,45 @@
                        EventHandler eh = (EventHandler) (Events 
[PreRenderCompleteEvent]);
                        if (eh != null) eh (this, e);
                }
+
+               if (Form == null)
+                       return;
+               if (!Form.DetermineRenderUplevel ())
+                       return;
+
+               /* figure out if we have some control we're going to focus */
+               if (String.IsNullOrEmpty (_focusedControlID)) {
+                       _focusedControlID = Form.DefaultFocus;
+                       if (String.IsNullOrEmpty (_focusedControlID))
+                               _focusedControlID = Form.DefaultButton;
+               }
+
+               if (!String.IsNullOrEmpty (_focusedControlID) || 
Form.SubmitDisabledControls) {
+
+                       RequiresPostBackScript ();
+                       ClientScript.RegisterWebFormClientScript ();
+
+                       if (!String.IsNullOrEmpty (_focusedControlID)) {
+                               ClientScript.RegisterStartupScript 
("HtmlForm-DefaultButton-StartupScript",
+                                                                        
String.Format ("<script type=\"text/javascript\">\n" +
+                                                                               
        "<!--\n" +
+                                                                               
        "WebForm_AutoFocus('{0}');// -->\n" +
+                                                                               
        "</script>\n", _focusedControlID));
+                       }
+
+                       if (Form.SubmitDisabledControls) {
+                               ClientScript.RegisterOnSubmitStatement 
("HtmlForm-SubmitDisabledControls-SubmitStatement",
+                                                                               
 "javascript: return WebForm_OnSubmit();");
+                               ClientScript.RegisterStartupScript 
("HtmlForm-SubmitDisabledControls-StartupScript",
+@"<script language=""JavaScript"">
+<!--
+function WebForm_OnSubmit() {
+WebForm_ReEnableControls();
+return true;
+} // -->
+</script>");
+                       }
+               }
        }
        
        protected virtual void OnSaveStateComplete (EventArgs e)
@@ -1838,6 +1879,28 @@
                }
        }
        
+       public void SetFocus (string clientID)
+       {
+               if (String.IsNullOrEmpty (clientID))
+                       throw new ArgumentNullException ("control");
+
+               if (_lifeCycle > PageLifeCycle.PreRender)
+                       throw new InvalidOperationException ("SetFocus can only 
be called before and during PreRender.");
+
+               if(Form==null)
+                       throw new InvalidOperationException ("A form tag with 
runat=server must exist on the Page to use SetFocus() or the Focus property.");
+
+               _focusedControlID = clientID;
+       }
+
+       public void SetFocus (Control control)
+       {
+               if (control == null)
+                       throw new ArgumentNullException ("control");
+
+               SetFocus (control.ClientID);
+       }
+       
        [EditorBrowsable (EditorBrowsableState.Advanced)]
        public void RegisterRequiresControlState (Control control)
        {

Modified: trunk/mcs/class/System.Web/System.Web.UI/PageLifeCycle.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI/PageLifeCycle.cs   2006-11-27 
12:52:08 UTC (rev 68507)
+++ trunk/mcs/class/System.Web/System.Web.UI/PageLifeCycle.cs   2006-11-27 
13:22:55 UTC (rev 68508)
@@ -40,6 +40,7 @@
        ControlEvents,
        LoadComplete,
        PreRender,
+       PreRenderComplete,
        SaveStateComplete,
        Render,
        Unload,

Modified: trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog     
2006-11-27 12:52:08 UTC (rev 68507)
+++ trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog     
2006-11-27 13:22:55 UTC (rev 68508)
@@ -1,3 +1,8 @@
+2006-11-27  Igor Zelmanovich  <[EMAIL PROTECTED]>
+
+       * HtmlForm.cs: refactoring: Registering of client scripts
+       moved to Page.            
+
 2006-11-17  Marek Habersack  <[EMAIL PROTECTED]>
 
        * HtmlInputHidden.cs: Added support for event validation.

Modified: trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlForm.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlForm.cs   
2006-11-27 12:52:08 UTC (rev 68507)
+++ trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlForm.cs   
2006-11-27 13:22:55 UTC (rev 68508)
@@ -225,55 +225,7 @@
 
                protected internal override void OnPreRender (EventArgs e)
                {
-                       string focus_id = null;
-                       bool need_script_block = false;
-                       bool render_uplevel;
-
                        base.OnPreRender(e);
-
-                       render_uplevel = DetermineRenderUplevel ();
-
-                       /* figure out if we have some control we're going to 
focus */
-                       if (DefaultFocus != null && DefaultFocus != "")
-                               focus_id = DefaultFocus;
-                       else if (DefaultButton != null && DefaultButton != "")
-                               focus_id = DefaultButton;
-
-                       /* decide if we need to include the script block */
-                       need_script_block = (focus_id != null || 
submitdisabledcontrols);
-
-                       if (render_uplevel) {
-                               Page.RequiresPostBackScript();
-
-                               if (need_script_block && 
!Page.ClientScript.IsClientScriptBlockRegistered 
("Mono-System.Web-HtmlScriptBlock")) {
-                                       
Page.ClientScript.RegisterClientScriptBlock ("Mono-System.Web-HtmlScriptBlock",
-                                                                               
     String.Format ("<script language=\"JavaScript\" src=\"{0}\"></script>",
-                                                                               
                    Page.ClientScript.GetWebResourceUrl (GetType(),
-                                                                               
                                                         "webform.js")));
-                               }
-
-
-                               if (focus_id != null) {
-                                       Page.ClientScript.RegisterStartupScript 
("HtmlForm-DefaultButton-StartupScript",
-                                                                               
 String.Format ("<script language=\"JavaScript\">\n" + 
-                                                                               
                "<!--\n" + 
-                                                                               
                "WebForm_AutoFocus('{0}');// -->\n" + 
-                                                                               
                "</script>\n", focus_id));
-                               }
-
-                               if (submitdisabledcontrols) {
-                                       
Page.ClientScript.RegisterOnSubmitStatement 
("HtmlForm-SubmitDisabledControls-SubmitStatement",
-                                                                               
     "javascript: return WebForm_OnSubmit();");
-                                       Page.ClientScript.RegisterStartupScript 
("HtmlForm-SubmitDisabledControls-StartupScript",
-@"<script language=""JavaScript"">
-<!--
-function WebForm_OnSubmit() {
-WebForm_ReEnableControls();
-return true;
-} // -->
-</script>");
-                               }
-                       }
                }
 #endif         
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to