public void AddButton() { // Add a standard button. Button b = new Button(); b.Text = "New standard button"; RootDesigner.AddControlToDocument(b, null, ControlLocation.First); }
public string MapPath(string originalPath) { string result = null; var site = Component.Site; if (site != null) { var vWA = (IWebApplication)site.GetService(typeof(IWebApplication)); if (vWA != null) { var path = originalPath.Replace("/", "\\"); var fromRoot = false; while (path.Length > 0 && (path.Substring(0, 1) == "\\" || path.Substring(0, 1) == "~")) { fromRoot = true; path = path.Substring(1); if (path.Length == 0) { break; } } var fAppRootFolder = vWA.RootProjectItem.PhysicalPath; if (fromRoot) { result = Path.Combine(fAppRootFolder, path); } else { var pageUrl = Path.GetDirectoryName(RootDesigner.DocumentUrl).Replace("/", "\\"); while (pageUrl.Length > 0 && (pageUrl.Substring(0, 1) == "\\" || pageUrl.Substring(0, 1) == "~")) { pageUrl = pageUrl.Substring(1); if (pageUrl.Length == 0) { break; } } result = Path.Combine(Path.Combine(fAppRootFolder, pageUrl), path); } result = RootDesigner.ResolveUrl(result).Substring(8).Replace("/", "\\"); if (result.IndexOf(fAppRootFolder, StringComparison.OrdinalIgnoreCase) != 0) // outside Web Application { result = null; } } } return(result); }
public void AddNewButton() { // Add your custom button. NewButton b = new NewButton(); b.Text = "New custom button"; // For buttons defined in a different assembly, add the // register directive for the referenced assembly. // assembly. By default, this goes to the document, unless // already defined in the document or in configuration. WebFormsReferenceManager wfrm = RootDesigner.ReferenceManager; wfrm.RegisterTagPrefix(b.GetType()); RootDesigner.AddControlToDocument(b, null, ControlLocation.Last); }