radtreeview节点没有触发onClick事件?

时间:2013-08-27 18:36:36

标签: c# javascript asp.net telerik

我有一个radtreeview,由后面的代码中的DB填充。我有一个简单的点击功能,我想解雇,但它似乎没有工作。这可能很简单。后面的代码有点难看,但没有做任何复杂的事情。这是我的aspx和代码背后:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="frmMain.aspx.cs" Inherits="MCMwebapp.frmMain" %>

 <script type="text/javascript" language="javascript">
     function ClientNodeClicked(sender, eventArgs) {
         var node = eventArgs.get_node();
         alert("You clicked " + node.get_text());
     }

由于某种原因,结束脚本标签没有在编辑器上显示..

   < telerik:RadTreeView ID="sitesTree" runat="server" OnClientNodeClicked="ClientNodeClicked">
            <WebServiceSettings Path="MCMwebservice.Service1.asmx" Method="" />
    </telerik:RadTreeView>

这是填充我的树的函数:

  public void LoadSites(ref RadTreeView TreeSites, string Demogs, string Agencies, bool Config)
    {
        // Declare the SslConnection class variable.
        SqlConnection sStateConn = new SqlConnection(Util.ConStrEpcrProd);
        SqlConnection sZonesConn = new SqlConnection(Util.ConStrEpcrProd);
        SqlConnection sAgenciesConn = new SqlConnection(Util.ConStrEpcrProd);
        SqlCommand sStatesCmd = new SqlCommand("SELECT DISTINCT State FROM AMR_ZONE WHERE Zone_ID IN (" + Demogs + ") ORDER BY State");
        SqlCommand sZonesCmd = new SqlCommand();
        SqlCommand sAgenciesCmd = new SqlCommand();
        sZonesCmd.Connection = sZonesConn;
        sAgenciesCmd.Connection = sAgenciesConn;
        sStatesCmd.Connection = sStateConn;
        SqlDataReader objZonesReader;
        SqlDataReader objAgenciesReader;
        SqlDataReader objStateReader;

        try
        {
            sStateConn.Open();
            sZonesConn.Open();
            sAgenciesConn.Open();

            objStateReader = sStatesCmd.ExecuteReader();
            TreeSites.Nodes.Add(new RadTreeNode("MEDS", "MEDSRoot"));


            while (objStateReader.Read())
            {
                RadTreeNode StateNode = new RadTreeNode(objStateReader["State"].ToString());
                StateNode.Text = objStateReader["State"].ToString();

                (TreeSites.FindNodeByText("MEDS")).Nodes.Add(StateNode);

                sZonesCmd.CommandText = "SELECT State,County,Zone_ID FROM AMR_ZONE WHERE State = '" + objStateReader["State"].ToString() + "' AND Zone_ID IN (" + Demogs + ") ORDER BY County";
                objZonesReader = sZonesCmd.ExecuteReader();

                while (objZonesReader.Read())
                {
                    RadTreeNode ZoneNode = new RadTreeNode(objZonesReader["County"].ToString());
                    ZoneNode.Text = objZonesReader["Zone_ID"].ToString();
                    bool p = ZoneNode.PostBack;
                    (TreeSites.FindNodeByText("MEDS")).Nodes[StateNode.Index].Nodes.Add(ZoneNode);
                    if (!Config)
                    {
                        // If the sites are being loaded to grant user permissions, then load the agencies as well.
                        sAgenciesCmd.CommandText = "SELECT [DESC], CODE, Demog FROM AMR_AGEN WHERE Demog = " + ZoneNode.Text + " AND CODE IN(" + Agencies + ") ORDER BY [DESC]";
                        objAgenciesReader = sAgenciesCmd.ExecuteReader();

                        while (objAgenciesReader.Read())
                        {
                            RadTreeNode AgencyNode = new RadTreeNode(objAgenciesReader["DESC"].ToString());
                            //AP 1/24/2010 changed to name the node with the CODE value
                            //AgencyNode.Name = objAgenciesReader["DESC"].ToString();
                            AgencyNode.Text = objAgenciesReader["CODE"].ToString();
                            AgencyNode.Value = objAgenciesReader["CODE"].ToString() + objAgenciesReader["Demog"].ToString();
                            (TreeSites.FindNodeByText("MEDS")).Nodes[StateNode.Index].Nodes[ZoneNode.Index].Nodes.Add(AgencyNode);
                        }

                        objAgenciesReader.Close();
                        objAgenciesReader.Dispose();
                    }
                }

                objZonesReader.Close();
                objZonesReader.Dispose();
            }

            objStateReader.Close();
            objStateReader.Dispose();

        }
        catch (SqlException SqlEx)
        {
            MessageBox.Show("Database error. Please contact your administrator. LoadSite(): "
                + SqlEx.Message, "MEDS Configuration Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
        catch (Exception ex)
        {
            MessageBox.Show("Error -  LoadSite(): "
                + ex.Message, "MEDS Configuration Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
        finally
        {
            sStateConn.Close();
            sStateConn.Dispose();
            sAgenciesConn.Close();
            sAgenciesConn.Dispose();
            sZonesConn.Close();
            sZonesConn.Dispose();
            sStatesCmd.Dispose();
            sZonesCmd.Dispose();
            sAgenciesCmd.Dispose();
        }
    }//      



}

1 个答案:

答案 0 :(得分:0)

尝试改变这一点:

< telerik:RadTreeView ID="sitesTree" runat="server" ...

进入这个:

<telerik:RadTreeView ID="sitesTree" runat="server" ...