public static object TreeViewMoveItem(string ParentFolderId, string ItemId)
        {
            try
            {

                int id = int.Parse(ItemId.Substring(1));
                int? pid = (string.IsNullOrEmpty(ParentFolderId)) ? (int?)null : int.Parse(ParentFolderId.Substring(1));

                // skip move to a list
                if (ParentFolderId.StartsWith("s"))
                    return new { Status = false, Message = "TREECANNOTMOVE" };

                if (ItemId.StartsWith("f"))
                {
                    FolderData fd = new Folders().GetFolderById(id);
                    FolderData.TreeNodesRow tn = (FolderData.TreeNodesRow)fd.TreeNodes.Rows[0];

                    if ((tn.ParentFolderId != null) && pid.HasValue)
                        new Folders().MoveFolder(pid, id);
                    else
                        return new { Status = false, Message = "TREECANNOTMOVE" };
                }
                else if (ItemId.StartsWith("s"))
                {
                    Surveys srv = new Surveys();

                    int sid;
                    if (int.TryParse(ItemId.Substring(1), out sid))
                    {
                        srv.SetFolderId(pid, sid);
                    }
                }
                return new { Status = true, Message = string.Empty };
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                if (ex.Message == "DUPLICATEFOLDER")   return new { Status = false, Message = ex.Message };
                throw;
            }
       
        }
        private void ImportXMLButton_Click(object sender, System.EventArgs e)
        {
            if (ImportFile.PostedFile != null)
            {
                NSurveyForm importedSurveys = new NSurveyForm();
                try
                {

                    importedSurveys.ReadXml(ImportFile.PostedFile.InputStream);
                    if (importedSurveys.Survey.Rows.Count > 0)
                    {
                        // Prevents SQL injection from custom hand written datasources Sql answer types in the import Xml 
                        if (!GlobalConfig.SqlBasedAnswerTypesAllowed || !(((PageBase)Page).NSurveyUser.Identity.IsAdmin || ((PageBase)Page).CheckRight(NSurveyRights.SqlAnswerTypesEdition, false)))
                        {
                            foreach (NSurveyForm.AnswerTypeRow answerType in importedSurveys.AnswerType)
                            {
                                answerType.DataSource = null;
                            }
                        }

                        new Survey().ImportSurveys(importedSurveys, ((PageBase)Page).NSurveyUser.Identity.UserId, ((PageBase)Page).SelectedFolderId ?? -1);
                        Surveys srv = new Surveys();
                        srv.SetFolderId(((PageBase)Page).SelectedFolderId, importedSurveys.Survey[0].SurveyID);

                        AssignSurveyToUser(importedSurveys.Survey[0].SurveyID);
                        SurveyId = importedSurveys.Survey[0].SurveyID;
                        UINavigator.NavigateToSurveyBuilder(importedSurveys.Survey[0].SurveyID, 4);
                        ((PageBase)Page).ShowNormalMessage(MessageLabel, ((PageBase)Page).GetPageResource("SurveyImported"));
                    }

                    else ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("SurveyNotImported"));


                    MessageLabel.Visible = true;
                }
                catch (Exception ex)
                {
                    if (ex.Message == "DUPLICATEFOLDER")
                        ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("SurveyImportDuplicate") );
                    else
                        ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("Exception") + "  " + ex.Message);
                    MessageLabel.Visible = true;
                }
            }
        }