PDA

View Full Version : [CLOSED] Radio without shooting the associated event



opendat2000
Oct 10, 2015, 2:16 PM
Hello Ext .Net

How can I set up initials values from a Radio without shooting the associated event, an alternative would be remove temporarily that event,
but the problem is ... How can I restore it?

I was reviewing the forum and found the following link:

http://forums.ext.net/showthread.php?23258-CLOSED-Delete-Remove-directevent-handler-in-code-behind&highlight=SuspendEvent

I've built an example to illustrate my idea, these would be the steps to follow to understand my problem.

1. Select option “abcd”
2. Click over button “Option Default”, this result in that the event will shooting the “Radio_Change” event.




<%@ Page Language="C#" AutoEventWireup="true" %>

<%@ Import Namespace="System.Collections.Generic" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
}
}
protected void Radio_Change(object sender, DirectEventArgs e)
{
try
{
if (Radio1.Checked == true)
{
TextField1.Text += "abcd";
}
else if (Radio2.Checked == true)
{
TextField1.Text += "1234";
}
}
catch (Exception)
{
}
}

protected void Button1_Click(object sender, DirectEventArgs e)
{
FormPanel1.Reset();
}
</script>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">

<ext:ResourceManager ID="ResourceManager1" runat="server" />

<ext:Window ID="Window1" runat="server"
Title="Form View"
Width="440"
Height="310"
BodyPadding="15"
Resizable="false"
Closable="false"
Layout="Fit">
<Items>
<ext:FormPanel ID="FormPanel1" runat="server"
Border="false"
Layout="Form">
<Items>
<ext:RadioGroup ID="RadioGroup1" runat="server"
FieldLabel="RadioGroup1"
LabelAlign="Left"
Anchor="60%">
<Items>
<ext:Radio runat="server" ID="Radio1" BoxLabel="abcd" LabelAlign="Right" Name="Radio1">
<DirectEvents>
<Change OnEvent="Radio_Change"></Change>
</DirectEvents>
</ext:Radio>
<ext:Radio runat="server" ID="Radio2" BoxLabel="1234" LabelAlign="Right" Name="Radio2" Checked="true">
<DirectEvents>
<Change OnEvent="Radio_Change"></Change>
</DirectEvents>
</ext:Radio>
</Items>
</ext:RadioGroup>
<ext:TextField ID="TextField1" runat="server" Name="TextField1"
FieldLabel="TextField1"
ReadOnly="true" >
</ext:TextField>
</Items>
</ext:FormPanel>
</Items>
<TopBar>
<ext:Toolbar ID="Toolbar1" runat="server">
<Items>
<ext:Button ID="Button1" runat="server" Icon="Erase" Text="Option Default">

<DirectEvents>
<Click OnEvent="Button1_Click"></Click>
</DirectEvents>

</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
</ext:Window>
</form>
</body>
</html>



Regards.

Daniil
Oct 12, 2015, 7:30 AM
Hi @opendat2000,

Please use:

protected void Button1_Click(object sender, DirectEventArgs e)
{
this.Radio1.SuspendEvent("change");
this.Radio2.SuspendEvent("change");
this.FormPanel1.Reset();
this.Radio1.ResumeEvent("change");
this.Radio2.ResumeEvent("change");
}

opendat2000
Oct 13, 2015, 12:57 PM
Hi Daniil,

Thanks a lot for your reply, the code line you proposed worked perfectly.

Please close the thread.

Saludos
Mauricio.