Beispiel #1
0
 public SmartPageInfo(ISmartPage page)
 {
     ArgumentUtility.CheckNotNullAndType <Page> ("page", page);
     _page       = page;
     _page.Init += Page_Init;
     // PreRenderComplete-handler must be registered before ScriptManager registers its own PreRenderComplete-handler during OnInit.
     _page.PreRenderComplete += Page_PreRenderComplete;
 }
        /// <summary>
        ///   Gets the form's postback data in a fashion that works for WxePages too.
        ///   Otherwise simialar to <b>Page.Request.Form</b>.
        /// </summary>
        /// <param name="page"> The page to query for the request collection. Must not be <see langword="null"/>. </param>
        /// <returns>
        ///   The <see cref="NameValueCollection"/> returned by
        ///   <see cref="Remotion.Web.UI.ISmartPage.GetPostBackCollection">ISmartPage.GetPostBackCollection</see> or the
        ///   <see cref="HttpRequest.Form"/> collection of the <see cref="Page.Request"/>, depending on whether or not the
        ///   <paramref name="page"/> implements <see cref="IWxePage"/>.
        /// </returns>
        public static NameValueCollection GetPostBackCollection(IPage page)
        {
            ISmartPage smartPage = page as ISmartPage;

            if (smartPage != null)
            {
                return(smartPage.GetPostBackCollection());
            }
            else
            {
                return(page.Request.Form);
            }
        }
Beispiel #3
0
        public void RegisterForSynchronousPostBackOnDemand([NotNull] Control control, [NotNull] string argument, [NotNull] string commandID)
        {
            ArgumentUtility.CheckNotNull("control", control);
            ArgumentUtility.CheckNotNullOrEmpty("argument", argument);
            ArgumentUtility.CheckNotNullOrEmpty("commandID", commandID);

            bool isSynchronousEventCommand       = Type == CommandType.Event && EventCommand.RequiresSynchronousPostBack;
            bool isSynchronousWxeFunctionCommand = Type == CommandType.WxeFunction && string.IsNullOrEmpty(WxeFunctionCommand.Target);

            if (!isSynchronousEventCommand && !isSynchronousWxeFunctionCommand)
            {
                return;
            }

            if (!ControlHelper.IsNestedInUpdatePanel(control))
            {
                return;
            }

            if (isSynchronousEventCommand)
            {
                ISmartPage smartPage = control.Page as ISmartPage;
                if (smartPage == null)
                {
                    throw new InvalidOperationException(
                              string.Format(
                                  "{0}: EventCommands with RequiresSynchronousPostBack set to true are only supported on pages implementing ISmartPage when used within an UpdatePanel.",
                                  commandID));
                }
                smartPage.RegisterCommandForSynchronousPostBack(control, argument);
            }
            else if (isSynchronousWxeFunctionCommand)
            {
                ISmartPage smartPage = control.Page as ISmartPage;
                if (smartPage == null)
                {
                    throw new InvalidOperationException(
                              string.Format(
                                  "{0}: WxeCommands are only supported on pages implementing ISmartPage when used within an UpdatePanel.",
                                  commandID));
                }
                smartPage.RegisterCommandForSynchronousPostBack(control, argument);
            }
        }