Problem using js doPostBack to call button with directevents and passing extraparams

  1. #1

    Problem using js doPostBack to call button with directevents and passing extraparams

    Hello,
    I'd like to add a confirmation prompt using javascript. The javascript function called from code behind using DirectEvents on btncheck and then when users click 'yes', the js function call the hidden btnSubmit on my form and pass the extraparams to function on my codebehind. Herewith my code. Please help with this, the problem is that the doPostBack didn't call the btnSubmit directevents. Hopefully my question is clear enough.

    Also, If there are any simpler solution, please tell me. I simply just want to add a confirmation prompt before user click btnSubmit which also passing extraparams.

    Thank You

    This is my javascript code:
    <script type="text/javascript">
    function askConfirm() {
            var confirm = window.confirm("Are You sure? ");
            if (confirm) {
                __doPostBack(btnSubmit, '');
            }
        };
    </script>
    This is the aspx form:

    <td align="left" >
                    <ext:Button ID="btnSubmit" runat="server" Text="Release" Width="100"  Hidden="True">
                        <DirectEvents>
                            <Click OnEvent="btnSubmit_Click" >
                                <EventMask ShowMask="true" Msg="Please wait..." MinDelay="10"/>
                                 <ExtraParams>
                                 <ext:Parameter Name="record" value="Ext.encode(#{GridNew}.getRowsValues({selectedOnly:true}))" Mode="Raw" Encode="true" /></ExtraParams>
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                    <ext:Button ID="btncheck" runat="server" Text="Release" Width="100">
                        <DirectEvents>
                            <Click OnEvent="btnSubmitCheck_Click" >
                            </Click>
                        </DirectEvents>
                    </ext:Button>
    </td>
    And The Code Behind:

    Public Sub btnSubmitCheck_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btncheck.Click
            If X.IsAjaxRequest Then
                X.Js.Call("askConfirm()")
            End If
        End Sub
    
    Public Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSubmit.Click
            If X.IsAjaxRequest Then
                 X.Msg.Alert("Information","OK").Show()            
             End If
    End Sub
  2. #2
    Hi @raniara,

    Welcome to the Ext.NET forums!

    What about a DirectEvent's Confirmation? Please see the second Button in this example:
    https://examples2.ext.net/#/Events/D...ents/Overview/
  3. #3
    That works perfectly.

    Thank You Daniil.

Similar Threads

  1. Replies: 2
    Last Post: May 13, 2013, 2:05 PM
  2. [CLOSED] DirectEvent: passing via extraparams html content of a panel
    By tanky65 in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 02, 2013, 4:25 PM
  3. [CLOSED] ExtraParams in DirectEvents comes back 'null'
    By Fahd in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 22, 2012, 7:44 PM
  4. Common ExtraParams for all DirectEvents
    By wdk in forum 1.x Help
    Replies: 7
    Last Post: Apr 05, 2012, 2:26 AM
  5. [CLOSED] [1.0] Passing ExtraParams on Store OnRefreshData
    By state in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 01, 2010, 3:02 AM

Tags for this Thread

Posting Permissions