Aug 18, 2016, 3:35 PM
DirectMethod in Custom Server Control
Hello guys!
I am creating a custom server control, in which I make a call to a DirectMethod, but I have not managed to find how to make the call. Apparently DirectMethod not recorded. Could you tell me which is the best way or the right way to do it?
Thanks for all!!!
I am creating a custom server control, in which I make a call to a DirectMethod, but I have not managed to find how to make the call. Apparently DirectMethod not recorded. Could you tell me which is the best way or the right way to do it?
using System.Web.UI;
using Ext.Net;
using Microsoft.Build.Framework;
/// <summary>
/// Descripción breve de ValidarPermisoSupervisor
/// </summary>
[ToolboxData("<{0}:ValidateAccess runat=server></{0}:ValidateAccess>")]
[DirectMethodProxyID(IDMode = DirectMethodProxyIDMode.Alias, Alias = "ValidateAccess")]
public class ValidateAccess : System.Web.UI.WebControls.WebControl
{
[Required]
public string Application { get; set; }
[Required]
public string Operation { get; set; }
protected override void OnInit(EventArgs e)
{
if (!ExtNet.IsAjaxRequest)
{
Page.X().Window().
ID(String.Format("win_{0}", ID)).
Resizable(False).
Icon(Icon.Lock).
Width(350).
Height(150).
Title("Login").
Layout("fit").
Border(False).
Modal(True).
ButtonAlign(Alignment.Right).
Items(i =>
{
i.Add(
Page.X().FormPanel().
Header(False).
Border(False).
Padding(5).
Items(f =>
{
f.Add(
Page.X().TextField().
ID(String.Format("txtUserName_{0}", ID)).
FieldLabel("User").
AllowBlank(False).
BlankText("Username").
AnchorHorizontal("95%")
);
f.Add(
Page.X().TextField().
ID(String.Format("txtPassword_{0}", ID)).
InputType(InputType.Password).
FieldLabel("Password").
AllowBlank(False).
BlankText("Password").
AnchorHorizontal("95%")
);
})
);
}).
Buttons(b =>
{
var cmdAceptar = Page.X().Button().Text("Ok").Icon(Icon.Accept).ToComponent();
var cmdCancelar = Page.X().Button().Text("Cancel").Icon(Icon.Cancel).ToComponent();
//cmdAceptar.DirectEvents.Click.EventMask.ShowMask = True
//cmdAceptar.DirectEvents.Click.EventMask.Msg = "Validando credenciales..."
//AddHandler cmdAceptar.DirectEvents.Click.Event, Sub(s, a)
// ExtNet.Msg.Alert("validando", "Validando!").Show()
// End Sub
cmdAceptar.Listeners.Click.Handler = "Ext.net.Mask.show({ msg : 'Loading data...' }); #{DirectMethods}.Validate();";
//ctl00_ContentPlaceHolderBody_WucMesaCambio1_validaPermisoSupervisorTCManual
//win_validaPermisoSupervisorTCManual
//cmdCancelar.Listeners.Click.Handler = String.Format("#{0}.hide();", String.Format("win_{0}", ID))
b.Add(cmdAceptar);
b.Add(cmdCancelar);
}).
Hidden(True).
ToComponent().
AddTo(Me);
}
base.OnInit(e);
}
[DirectMethod()]
public void Validate()
{
X.Mask.Hide();
X.Msg.Alert("test", "Test").Show();
}
}
(I had to translate the code from VB to C# in the air, so if there is a typo error,please apologize)Thanks for all!!!