VirtualUserForm.aspx.cs
上传用户:husern
上传日期:2022-03-24
资源大小:534k
文件大小:3k
源码类别:

编辑器/阅读器

开发平台:

C#

  1. // -- FILE ------------------------------------------------------------------
  2. // name       : VirtualUserForm.cs
  3. // project    : Itenso Web User Forms
  4. // created    : Jani Giannoudis - 2008.10.30
  5. // language   : c#
  6. // environment: .NET 2.0
  7. // copyright  : (c) 2008 by Itenso GmbH, Switzerland
  8. // --------------------------------------------------------------------------
  9. using System;
  10. using System.Web.UI;
  11. using System.Web.Hosting;
  12. using System.Web.UI.WebControls;
  13. using System.Collections.Generic;
  14. using Itenso.WebUserForms.Controls;
  15. using Itenso.WebUserForms.Runtime;
  16. // --------------------------------------------------------------------------
  17. public partial class VirtualPage : System.Web.UI.Page
  18. {
  19. // ------------------------------------------------------------------------
  20. public VirtualPage()
  21. {
  22. } // VirtualPage
  23. // ------------------------------------------------------------------------
  24. private string WorkingFormName
  25. {
  26. get { return ViewState[ "WorkingForm" ] as string; }
  27. set { ViewState[ "WorkingForm" ] = value; }
  28. } // WorkingFormName
  29. // ------------------------------------------------------------------------
  30. private VirtualUserFormFileProvider FormProvider
  31. {
  32. get { return HostingEnvironment.VirtualPathProvider as VirtualUserFormFileProvider; }
  33. } // FormProvider
  34. // ------------------------------------------------------------------------
  35. protected override void OnLoad( EventArgs e )
  36. {
  37. if ( !IsPostBack )
  38. {
  39. VirtualUserFormFileProvider formProvider = FormProvider;
  40. if ( formProvider != null )
  41. {
  42. List<string> userFormNames = formProvider.GetAvailableUserForms();
  43. if ( userFormNames != null && userFormNames.Count > 0 )
  44. {
  45. FormListBox.DataSource = userFormNames;
  46. FormListBox.DataBind();
  47. FormListBox.SelectedIndex = 0;
  48. WorkingFormName = userFormNames[ 0 ];
  49. }
  50. }
  51. }
  52. SetupForm();
  53. base.OnLoad( e );
  54. } // OnLoad
  55. // ------------------------------------------------------------------------
  56. private void SetupForm()
  57. {
  58. FormPlaceHolder.Controls.Clear();
  59. string workingFormName = WorkingFormName;
  60. if ( string.IsNullOrEmpty( workingFormName ) )
  61. {
  62. return;
  63. }
  64. // load form control
  65. VirtualUserFormFileProvider formProvider = FormProvider;
  66. if ( formProvider != null )
  67. {
  68. string virtualFormName = formProvider.GetVirtualFormName( workingFormName );
  69. UserControl userForm = new UserFormLoader( virtualFormName, "virtForm" ).Load();
  70. FormPlaceHolder.Controls.Add( userForm );
  71. }
  72. } // SetupForm
  73. // ------------------------------------------------------------------------
  74. protected void FormListBox_SelectedIndexChanged( object sender, EventArgs e )
  75. {
  76. WorkingFormName = FormListBox.SelectedValue;
  77. SetupForm();
  78. } // FormListBox_SelectedIndexChanged
  79. } // class VirtualPage
  80. // -- EOF -------------------------------------------------------------------