Feb 14, 2011, 9:10 AM
[CLOSED] Multi Select Click event added as Attribute in 0.8.3 not working in 1.0
Hi Team,
I have MultiSelect in my project. I have added Javascript event handler to "onclick" event from the code behind to MultiSelect Control in 0.8.3.
Based on the selection of the items I am enabling and disabling button on the same page.
My "View" button should be enabled only when a item is selected with some custom conditions enabled. If none of the items selected, the "view" button should be disabled.
Reason why I used "onclick" attribute from code behind is, even when the user clicks on "Area" other than "Items Area" as show in picture,
should disable the "View" Button.
After migrating to 1.0, click event handler added from code-behind is not fired.
Could you please suggest me a work around?
I have MultiSelect in my project. I have added Javascript event handler to "onclick" event from the code behind to MultiSelect Control in 0.8.3.
Based on the selection of the items I am enabling and disabling button on the same page.
My "View" button should be enabled only when a item is selected with some custom conditions enabled. If none of the items selected, the "view" button should be disabled.
Reason why I used "onclick" attribute from code behind is, even when the user clicks on "Area" other than "Items Area" as show in picture,
should disable the "View" Button.
After migrating to 1.0, click event handler added from code-behind is not fired.
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
string script = string.Empty;
script += "EnableButtons(" + lstFiles.ClientID + "," + btnRemove.ClientID + "," + btnViewDocument.ClientID + ");";
lstFiles.AddScript(script);
lstFiles.Attributes.Add("onclick", script);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Multi Select Click worked fine with 0.8.3</title>
</head>
<body>
<form id="form1" runat="server">
<ext:ScriptManager ID="extScriptManager" runat="server">
</ext:ScriptManager>
<script type="text/javascript" language="javascript">
function EnableButtons(lstFiles, btnRemove, btnViewDocument)
{
/* As id sometimes getting dynamic ext id whcih returns component as null,
so name passed to Ext.getCmp */
//debugger;
var ellstFiles = Ext.getCmp(lstFiles.id) || Ext.getCmp(lstFiles.name);
var elbtnRemove = Ext.getCmp(btnRemove.id);
var elbtnViewDocument = Ext.getCmp(btnViewDocument.id);
if (ellstFiles)
{
var selectedValue = ellstFiles.getValue();
if (selectedValue == '') elbtnRemove.disable(); else elbtnRemove.enable();
elbtnViewDocument.disable();
var enable = parseInt(ellstFiles.getValue()) % 2 == 0 ? true : false;
if (enable)
{
elbtnViewDocument.enable();
}
else
{
elbtnViewDocument.disable();
}
}
}
</script>
<ext:MultiSelect ID="lstFiles" runat="server" MultiSelect="false" Height="200">
<Items>
<ext:ListItem Text="One" Value="1" />
<ext:ListItem Text="Two" Value="2" />
<ext:ListItem Text="Three" Value="3" />
<ext:ListItem Text="Four" Value="4" />
<ext:ListItem Text="Five" Value="5" />
<ext:ListItem Text="Six" Value="6" />
</Items>
</ext:MultiSelect>
<ext:Button ID="btnViewDocument" Text="View" runat="server">
<Listeners>
<Click Handler="Ext.Msg.alert('Selected Value', #{lstFiles}.getValue());" />
</Listeners>
</ext:Button>
<ext:Button ID="btnRemove" Text="Remove" runat="server">
</ext:Button>
</form>
</body>
</html>
Test this code both with 0.8.3 version and also 1.0.Could you please suggest me a work around?
Last edited by Daniil; Feb 16, 2011 at 8:37 AM.
Reason: [CLOSED]