Apr 02, 2014, 11:59 AM
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:
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