I have an ext:button. I want to trigger it's OnClick event by JavaScript based on the condition of a confirm message.
My Button
<ext:Button ID="btnAddEsya" Text="text" runat="server" Icon="Add" >
<DirectEvents>
<Click OnEvent="btnAddEsya_Click" ViewStateMode="Enabled">
</Click>
</DirectEvents>
</ext:Button>
Code Behind (only relevant parts)
[DirectMethod]
public void btnAddEsya_Click(object sender, EventArgs e)
{
if (/*Checking conditions here*/)
{
X.Msg.Confirm("Warning", "Save?", new JFunction { Fn = "SaveLine" }).Show();
}
}
Java Script
<script language="javascript" type="text/javascript">
var SaveLine = function (btn) {
if (btn == 'yes') {
alert('TEST YES');
NewLine.click();
document.getElementById('btnAddEsya').click();
}
else if (btn == 'no')
{ alert('TEST NO'); }
};
</script>
So far I tried this method, the __doPostBack('btnAddEsya','OnClick'); method and assigning the buttons to variables and calling them as variablename.click(). None of them worked.
Can it be about ext.net buttons Click OnEvent ?
Edit:
Recently I tried this too, and it didn't work either. Also
<script language="javascript" type="text/javascript">
btnAddEsya = document.getElementById('<%= btnAddEsya.ClientID %>');
var SaveLine = function (btn) {
if (btn == 'yes') {
alert('TEST YES');
btnAddEsya.click();
}
else if (btn == 'no')
{ alert('TEST NO'); }
};
</script>