/// <summary> Executes the <see cref="WxeFunction"/> defined by the <see cref="WxeFunctionCommandInfo"/>. </summary> /// <param name="wxePage"> /// The <see cref="IWxePage"/> where this command is rendered on. Must not be <see langword="null"/>. /// </param> /// <param name="additionalWxeParameters"> /// The parameters passed to the <see cref="WxeFunction"/> in addition to the executing function's variables. /// Use <see langword="null"/> or an empty collection if all parameters are supplied by the /// <see cref="WxeFunctionCommandInfo.Parameters"/> string and the function stack. /// </param> /// <exception cref="InvalidOperationException"> /// <para> /// Thrown if called while the <see cref="Type"/> is not set to <see cref="CommandType.WxeFunction"/>. /// </para><para> /// Thrown if neither the <see cref="WxeFunctionCommandInfo.MappingID"/> nor the /// <see cref="WxeFunctionCommandInfo.TypeName"/> are set. /// </para><para> /// Thrown if the <see cref="WxeFunctionCommandInfo.MappingID"/> and <see cref="WxeFunctionCommandInfo.TypeName"/> /// specify different functions. /// </para> /// </exception> public virtual void ExecuteWxeFunction(IWxePage wxePage, NameObjectCollection additionalWxeParameters) { ArgumentUtility.CheckNotNull("wxePage", wxePage); if (Type != CommandType.WxeFunction) { throw new InvalidOperationException("Call to ExecuteWxeFunction not allowed unless Type is set to CommandType.WxeFunction."); } if (!wxePage.IsReturningPostBack) { string target = WxeFunctionCommand.Target; bool hasTarget = !string.IsNullOrEmpty(target); WxeFunction function = WxeFunctionCommand.InitializeFunction(additionalWxeParameters); IWxeCallArguments callArguments; if (hasTarget) { callArguments = new WxeCallArguments((Control)OwnerControl, new WxeCallOptionsExternal(target, null, false)); } else { callArguments = WxeCallArguments.Default; } try { wxePage.ExecuteFunction(function, callArguments); } catch (WxeCallExternalException) { } } }
/// <summary>Executes the <paramref name="function"/> in the current window without triggering the current post-back event on returning.</summary> /// <remarks>This overload tries to determine automatically whether the current event was caused by the <c>__EVENTTARGET</c> field.</remarks> /// <include file='..\..\doc\include\ExecutionEngine\WxePageExtensions.xml' path='WxePageExtensions/ExecuteFunctionNoRepost/param[@name="page" or @name="function" or @name="sender" or @name="createPermaUrl" or @name="useParentPermaUrl" or @name="permaUrlParameters"]' /> public static void ExecuteFunctionNoRepost( this IWxePage page, WxeFunction function, Control sender, bool createPermaUrl, bool useParentPermaUrl, NameValueCollection permaUrlParameters) { var permaUrlOptions = CreatePermaUrlOptions(createPermaUrl, useParentPermaUrl, permaUrlParameters); var options = new WxeCallOptionsNoRepost(permaUrlOptions); var arguments = new WxeCallArguments(sender, options); Execute(page, function, arguments); }
/// <summary> /// Executes a <see cref="WxeFunction"/> outside the current function's context (i.e. asynchron) using the /// current window or frame. The execution engine uses a redirect request to transfer the execution to the new function. /// </summary> /// <include file='..\..\doc\include\ExecutionEngine\WxePageExtensions.xml' path='WxePageExtensions/ExecuteFunctionExternal/param[@name="page" or @name="function" or @name="sender" or @name="createPermaUrl" or @name="useParentPermaUrl" or @name="urlParameters" or @name="returnToCaller" or @name="callerUrlParameters"]' /> public static void ExecuteFunctionExternal( this IWxePage page, WxeFunction function, Control sender, bool createPermaUrl, bool useParentPermaUrl, NameValueCollection urlParameters, bool returnToCaller, NameValueCollection callerUrlParameters) { var permaUrlOptions = CreatePermaUrlOptions((createPermaUrl || urlParameters != null), useParentPermaUrl, urlParameters); var options = new WxeCallOptionsExternalByRedirect(permaUrlOptions, returnToCaller, callerUrlParameters); var arguments = new WxeCallArguments(sender, options); Execute(page, function, arguments); }
/// <summary> /// Executes a <see cref="WxeFunction"/> outside the current function's context (i.e. asynchron) using the /// specified window or frame through javascript window.open(...). /// </summary> /// <include file='..\..\doc\include\ExecutionEngine\WxePageExtensions.xml' path='WxePageExtensions/ExecuteFunctionExternal/param[@name="page" or @name="function" or @name="target" or @name="features" or @name="sender" or @name="returningPostback" or @name="createPermaUrl" or @name="useParentPermaUrl" or @name="urlParameters"]' /> public static void ExecuteFunctionExternal( this IWxePage page, WxeFunction function, string target, string features, Control sender, bool returningPostback, bool createPermaUrl, bool useParentPermaUrl, NameValueCollection urlParameters) { var permaUrlOptions = CreatePermaUrlOptions(createPermaUrl, useParentPermaUrl, urlParameters); var options = new WxeCallOptionsExternal(target, features, returningPostback, permaUrlOptions); var arguments = new WxeCallArguments(sender, options); Execute(page, function, arguments); }