/// <summary> /// Show specified control in ContentControl /// specified by ContentPlaceholder property. /// </summary> /// <param name="controlTypeName"> /// Assembly qualified control name to show. /// </param> /// <param name="paramerers"> /// String that incorporates parameters needed for new control /// </param> public void Navigate(string controlTypeName, string paramerers) { NavigationEventArgs args = new NavigationEventArgs(controlTypeName, paramerers, false); OnBeforeNavigation(args); if (!args.Cancel) { string title = string.Empty; CreateAndShowControl((Control)Activator.CreateInstance(Csla.Reflection.MethodCaller.GetType(controlTypeName)), args.Parameters, title, true, false); OnAfterNavigation(); } else { if (args.RedirectToOnCancel != null) { CreateAndShowControl((Control)Activator.CreateInstance(Csla.Reflection.MethodCaller.GetType(args.RedirectToOnCancel.ControlTypeName)), args.RedirectToOnCancel.Parameters, args.RedirectToOnCancel.Title, true, true); } } }
private bool ParseAndProcessBookmark(string bookmark) { bool success = false; if (bookmark.Length > 0 && bookmark.Contains(_bookmarkPartsSeparator)) { string[] bookmarkParts = bookmark.Split((new string[] { _bookmarkPartsSeparator }), StringSplitOptions.None); if (bookmarkParts.Length >= 3) { string controlName = bookmarkParts[0]; string title = bookmarkParts[1]; string parameters = bookmarkParts[2]; Control newControl = ControlNameFactory.ControlNameToControl(controlName); if (newControl != null) { NavigationEventArgs args = new NavigationEventArgs(newControl.GetType().AssemblyQualifiedName, parameters, true); OnBeforeNavigation(args); if (!args.Cancel) { CreateAndShowControl(newControl, args.Parameters, title, false, false); OnAfterBookmarkProcessing(true); success = true; } else { if (args.RedirectToOnCancel != null) { CreateAndShowControl((Control)Activator.CreateInstance(Csla.Reflection.MethodCaller.GetType(args.RedirectToOnCancel.ControlTypeName)), args.RedirectToOnCancel.Parameters, args.RedirectToOnCancel.Title, true, true); OnAfterBookmarkProcessing(true); success = true; } } } } } return success; }
/// <summary> /// Method that raises BeforeNavigation event. /// </summary> /// <param name="args"> /// Event argeuments for the event. /// </param> protected void OnBeforeNavigation(NavigationEventArgs args) { if (BeforeNavigation != null) { BeforeNavigation(this, args); } }