May 17, 2009, 11:20 AM
How to have scripts inside UserControl?
I'm trying to create a UserControl but can't quite figure out how to get scripts to work inside. The code I'm using is below. The nodeLoad is not working, even though this same code works if in a regular aspx page. Am I missing something here? I really need the scripting to be contained within the control, not outside of it.
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="FolderView.ascx.vb" Inherits="FolderView" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<style type="text/css">
.x-tree-node .x-tree-node-inline-icon{background:transparent;height:16px;width:16px;}
</style>
<script type="text/javascript">
function nodeLoad(node) {
Coolite.AjaxMethods.LoadFolder(node.id, {
success: function(result) {
var data = eval("(" + result + ")");
node.loadNodes(data);
},
failure: function(errorMsg) {
Ext.Msg.alert('Failure', errorMsg);
}
});
}
function nodeClear(node) {
while (node.hasChildNodes()) {
node.removeChild(node.item(0));
}
}
</script>
<ext:FitLayout ID="FitLayout1" runat="server">
<ext:TreePanel ID="TreePanel1" runat="server" Border="false" Animate="false">
<Listeners>
<BeforeLoad Fn="nodeLoad" />
</Listeners>
</ext:TreePanel>
</ext:FitLayout>