PDA

View Full Version : Confirm message Handler in CodeBehind



atroul
Mar 21, 2017, 11:47 AM
I need to open a dialog when I click a button so I here is what I have done:

Markup:


<ext:Button runat="server" ID="Button1" Text="Save New Information" OnDirectClick="Button1_DirectClick"/>

CodeBehind:


namespace Admin.Modules
{
public partial class UsersGrid : System.Web.UI.UserControl
{
protected void Button1_DirectClick(object sender, DirectEventArgs e)
{
X.Msg.Confirm("Confirm", "Do you want to update this information also?", new MessageBoxButtonsConfig
{
Yes = new MessageBoxButtonConfig
{
Handler = "App.Direct.DoYes()",
Text = "Yes"
},
No = new MessageBoxButtonConfig
{
Handler = "WndwEdit.close()",
Text = "No"
}
}).Show();
}

[DirectMethod]
public void DoYes()
{
X.MessageBox.Info("Error NOT", "Something went lalala", AnchorPoint.LeftTop, UI.Danger).Show();
}
}
}

The message box is displayed correctly but it doesnt call the DoYes function with error:


Uncaught TypeError: Cannot read property 'DoYes' of undefined

fabricio.murta
Mar 21, 2017, 8:24 PM
Hello @atroul!

Please use App.direct instead of App.Direct.

atroul
Mar 22, 2017, 4:53 PM
Hello Fabricio,

I did that change but now I receive this error:

Uncaught TypeError: App.direct.DoYes is not a function