How to Close RadWindow on save and refreshing Particular page by javascript

on design part of page of rad window write this javascript code

Code Snippet
  1. <script type="text/javascript">
  2.  
  3.         function CloseAndRedirect(sender, args) {
  4.             GetRadWindow().BrowserWindow.location.href = 'welcomePage.aspx';        //Redirect to new url
  5.             GetRadWindow().close();       //closes the window       
  6.         }
  7.         function GetRadWindow()   //Get reference to window    
  8.         {
  9.             var oWindow = null;
  10.             if (window.radWindow)
  11.                 oWindow = window.radWindow;
  12.             else if (window.frameElement.radWindow)
  13.                 oWindow = window.frameElement.radWindow;
  14.             return oWindow;
  15.         }
  16. </script>

on save button click

Code Snippet
  1. protected void btnSave_onClick(object sender, EventArgs e)
  2.    {
  3.      string script = "<script language='javascript' type='text/javascript'>Sys.Application.add_load(CloseAndRedirect);</script>";
  4.      Page.ClientScript.RegisterStartupScript(this.GetType(), "Close", script);  
  5.    }
Posted by: ritesh.kumar

Categories: Javascript, ASP.NET, Telerik

Tags:

Bind radtreeview with database

To bind radtreeview with database first get all the parents data items and bind that items to rad tree 

after that get child data of that parents items and then bind that data with rat tree view on NodeExpand event and so on.

Code Snippet
  1. protected void Page_Load(object sender, EventArgs e)
  2.         {
  3.  
  4.             if (!IsPostBack)
  5.             {
  6.  
  7.                 RadTreeNode parentNode = new RadTreeNode("Parent", "-1");
  8.                 parentNode.Font.Size = 14;
  9.                 parentNode.Font.Bold = true;
  10.                 parentNode.ForeColor = Color.SaddleBrown;
  11.                 parentNode.Expanded = true;
  12.                 parentNode.ImageUrl = "../Images/abc.png";
  13.                 parentNode.ExpandMode = TreeNodeExpandMode.ServerSideCallBack;
  14.                 parentNode.AllowEdit = false;
  15.                 RadTreeView1.Nodes.Add(parentNode);
  16.             }
  17.         }
  18.  
  19.         protected void RadTreeView1_NodeExpand(object sender, RadTreeNodeEventArgs e)
  20.         {
  21.  
  22.                    var result = e.Node.Value;
  23.                  var category = e.Node.Category;
  24.                if( e.Node.Category=="Parents")
  25.                     {
  26.                 var childNodes =  getChildDataBByParentId(int.Parse(result));
  27.                             if childNodes > 0)
  28.                             {
  29.                                 foreach (var child in childNodes )
  30.                                 {
  31.                                     RadTreeNode cA = new RadTreeNode();
  32.                                     cA.Font.Bold = true;
  33.                                     cA.Value = child.childID.ToString();
  34.                                     cA.ImageUrl = "../Images/Person.png";
  35.                                     cA.Text = child.childName;
  36.                                     cA.AllowEdit = false;
  37.                                     cA.ExpandMode = TreeNodeExpandMode.ServerSideCallBack;
  38.                                     cA.Category = "child";
  39.                                     parentNode.Nodes.Add(cA);
  40.  
  41.  
  42.                                 }
  43.                             }
  44.                      }
  45.               if( e.Node.Category=="child")
  46.                     {
  47.  
  48.                  var subChildNodes =  getSubChildData(int.Parse(result));
  49.                             if subChildNodes > 0)
  50.                             {
  51.                                 foreach (var subChild in subChildNodes )
  52.                                 {
  53.                                     RadTreeNode sA = new RadTreeNode();
  54.                                     sA.Font.Bold = true;
  55.                                     sA.Value = child.childID.ToString();
  56.                                     sA.ImageUrl = "../Images/Person.png";
  57.                                     sA.Text = child.childName;
  58.                                     sA.AllowEdit = false;
  59.                                     sA.ExpandMode = TreeNodeExpandMode.ServerSideCallBack;
  60.                                     sA.Category = "child";
  61.                                     cA.Nodes.Add(sA);
  62.  
  63.  
  64.                                 }
  65.                             }
  66.                     }
  67.  
  68.  
  69.         }
Posted by: ritesh.kumar

Categories: ASP.NET, Telerik

Tags: