PDA

View Full Version : [CLOSED] Msg.Confirm With DirectMethod Inside UserControl



jtorroledo
Jan 08, 2013, 1:51 AM

Aurelio
Jan 08, 2013, 4:31 AM
Hi...

I use this and work Ok.. SVN 2.1



ExtNet.Msg.Show(new MessageBoxConfig
{
Title = "Avviso",
Message = "Delete this user: " + rowUte.UteUte + " ?",
Width = 300,
Buttons = MessageBox.Button.YESNO,
MessageBoxButtonsConfig = new MessageBoxButtonsConfig
{
Yes = new MessageBoxButtonConfig
{
Text = "Si",
Handler = "Ext.net.DirectMethods.Delete()"
},
No = new MessageBoxButtonConfig
{
Text = "No"
}
},
Icon = MessageBox.Icon.QUESTION
});


[DirectMethod]
public void Delete()
{

}


But it's possible execute the test client side so as not to generate traffic to the server:

Client side:



<ext:Button ID="ButtonDelete" runat="server" Text="Cancella" Disabled="true" Scale="Medium"
IconUrl="Images/Icon/delete24.png" ToolTip="Cancella il cliente selezionato."
ToolTipType="Title">
<Listeners>
<Click Handler="DeleteCliente(#{GridPanelClienti}.getSelectionMode l().getLastSelected(),
'Avviso',
'Delete Cliente: ' + #{GridPanelClienti}.getSelectionModel().getLastSel ected().get('CliRagSoc') + ' ?')" />
</Listeners>
</ext:Button>

<script type="text/javascript">

var DeleteCliente = function (record, Title, Message) {

if (condition)
{
Ext.Msg.show({
title: Title,
msg: Message,
buttons: { yes: "Si", no: "No" },
icon: Ext.Msg.QUESTION,
fn: function (btn) {
if (btn == 'yes') {
Ext.net.DirectMethods.Delete(record.data.CliId);//send the id to delete
}
}
});
}
};
</script>






Server side



[DirectMethod]
public void DeleteCliente(int pCliId)
{

}



Thanks
Aurelio

Daniil
Jan 08, 2013, 10:13 AM
Hi everybody,

@Aurelio suggest a good thing. Really, if an action can be done client side, it is good to avoid an AJAX request.

If you really need a server action, please provide a full test case (but simplified) to reproduce the problem (an ASPX and an ASCX).

jtorroledo
Jan 08, 2013, 10:12 PM
Hello,

Aurelio thanks for the answer, but it still has the same error

Uncaught TypeError: Can not call method 'Doyes' of undefined



<script type="text/javascript">

var confirmacion = function () {


Ext.Msg.show({
title: "Aviso",
msg: "Desea grabar los datos antes de cerrar la ventana?",
buttons: { yes: "Si", no: "No" },
icon: Ext.Msg.QUESTION,
fn: function (btn) {
if (btn == 'yes') {
Ext.net.DirectMethods.DoYes();
}
}
});

};
</script>

<ext:Window runat="server" ID="WinFindCliente" AutoShow="false" Modal="true" Hidden="true"
Width="700" Height="270" BodyPadding="5" Title="Bloqueo del Cliente">
<Items>
<ext:Panel ID="Panel1" runat="server" BodyStyle="background-color:#F8F8F8; padding:5px; border:dotted 1px gray;"
Title="Datos del Cliente">
</ext:Panel>
<ext:Panel runat="server" BodyPadding="5">
<Items><ext:TextArea ID="txtRazon" runat="server" Width="670" FieldLabel="Razon del Bloqueo" LabelAlign="Top" LabelStyle="font-weight:bold;"/>
<ext:TextField runat="server" Visible="false" ID="txtDocumento"></ext:TextField>
</Items>

<Buttons>
<ext:Button ID="btnGrabar" runat="server" Text="Grabar" Icon="DatabaseSave">
<DirectEvents>
<Click OnEvent="BtnGrabarBloqueoClick"></Click>
</DirectEvents>
</ext:Button>
<ext:Button ID="btnCancelar" runat="server" Text="Cerrar" Icon="Cancel">
<Listeners>
<Click Handler="confirmacion();" />
</Listeners>
</ext:Button>
</Buttons>
</ext:Panel>

</Items>
</ext:Window>



in server side



[DirectMethod]
public void DoYes()
{
saveData();
WinFindCliente.Hide();
}




Hi...

I use this and work Ok.. SVN 2.1



ExtNet.Msg.Show(new MessageBoxConfig
{
Title = "Avviso",
Message = "Delete this user: " + rowUte.UteUte + " ?",
Width = 300,
Buttons = MessageBox.Button.YESNO,
MessageBoxButtonsConfig = new MessageBoxButtonsConfig
{
Yes = new MessageBoxButtonConfig
{
Text = "Si",
Handler = "Ext.net.DirectMethods.Delete()"
},
No = new MessageBoxButtonConfig
{
Text = "No"
}
},
Icon = MessageBox.Icon.QUESTION
});


[DirectMethod]
public void Delete()
{

}


But it's possible execute the test client side so as not to generate traffic to the server:

Client side:



<ext:Button ID="ButtonDelete" runat="server" Text="Cancella" Disabled="true" Scale="Medium"
IconUrl="Images/Icon/delete24.png" ToolTip="Cancella il cliente selezionato."
ToolTipType="Title">
<Listeners>
<Click Handler="DeleteCliente(#{GridPanelClienti}.getSelectionMode l().getLastSelected(),
'Avviso',
'Delete Cliente: ' + #{GridPanelClienti}.getSelectionModel().getLastSel ected().get('CliRagSoc') + ' ?')" />
</Listeners>
</ext:Button>

<script type="text/javascript">

var DeleteCliente = function (record, Title, Message) {

if (condition)
{
Ext.Msg.show({
title: Title,
msg: Message,
buttons: { yes: "Si", no: "No" },
icon: Ext.Msg.QUESTION,
fn: function (btn) {
if (btn == 'yes') {
Ext.net.DirectMethods.Delete(record.data.CliId);//send the id to delete
}
}
});
}
};
</script>






Server side



[DirectMethod]
public void DeleteCliente(int pCliId)
{

}



Thanks
Aurelio

Aurelio
Jan 09, 2013, 12:04 AM
HI... jtorroledo

In tne ResourceManager insert this:

DirectMethodNamespace="Ext.net.DirectMethods"



<ext:ResourceManager ID="ResourceManager1" runat="server" HideInDesign="True" Theme="Gray" DirectMethodNamespace="Ext.net.DirectMethods" />



Sorry I forgot to enter the command DirectMethodNamespace="Ext.net.DirectMethods" in the ResourceManager

It's work ok...

If you have indicate: DirectMethodNamespace="YY" in this case the Javascript here:



<script type="text/javascript">

var confirmacion = function () {


Ext.Msg.show({
title: "Aviso",
msg: "Desea grabar los datos antes de cerrar la ventana?",
buttons: { yes: "Si", no: "No" },
icon: Ext.Msg.QUESTION,
fn: function (btn) {
if (btn == 'yes') {
YY.DoYes();
}
}
});

};
</script>


It's work ok...

I use the versione 2.1 of Ext.Net in the directory Branches
Aurelio

Daniil
Jan 09, 2013, 5:14 AM
Please note that the default DirectMethodNamespace is "App.direct" in Ext.NET v2.

jtorroledo
Jan 10, 2013, 7:29 PM
Hi Daniil, Aurelio,

My DirectMethodNamespace not working properly, I used the examples of Aurelio and not working, I have tried with a new project with NutGet ext.net downloading but I've the same error

5412.

How I can validate if the installation of ext.net is successful?


Thanks!!

Please note that the default DirectMethodNamespace is "App.direct" in Ext.NET v2.

Vladimir
Jan 10, 2013, 7:41 PM
Please note that if DirectMethod inside user control then it will add additional namespace


App.direct.ClientIDOfUserControl.MerthodName

http://examples2.ext.net/#/Events/DirectMethods/UserControls/

You can set own alias (instead ClientID) or remove that alias via 'DirectMethodProxyID' attribute
See the following sample
http://examples2.ext.net/#/Events/DirectMethods/ID_Mode/

jtorroledo
Jan 11, 2013, 10:15 PM
Thanks!! it works well.