able to and/or how to programmatically loop through web forms VB.N

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ALthePal

    #1

    able to and/or how to programmatically loop through web forms VB.N

    Hi,

    I'm not sure if we are able to or even how to loop through the web forms in
    a VB.NET project during design time. In MSAccess we are able to go through
    the database -> forms collection and loop through all the forms in a database
    and pull information about the form (controls and properties). We would need
    to do the same in our VB.NET project; loop through the project and get the
    web form's control and property information programmaticall y. The information
    needs to get populated into a table in the database.

    If anyone has any ideas that would be most helpful.

    Thanks,
  • Tim

    #2
    RE: able to and/or how to programmaticall y loop through web forms VB.N

    Are you upsizing your Access app to a web app?

    "ALthePal" wrote:
    [color=blue]
    > Hi,
    >
    > I'm not sure if we are able to or even how to loop through the web forms in
    > a VB.NET project during design time. In MSAccess we are able to go through
    > the database -> forms collection and loop through all the forms in a database
    > and pull information about the form (controls and properties). We would need
    > to do the same in our VB.NET project; loop through the project and get the
    > web form's control and property information programmaticall y. The information
    > needs to get populated into a table in the database.
    >
    > If anyone has any ideas that would be most helpful.
    >
    > Thanks,[/color]

    Comment

    • ALthePal

      #3
      RE: able to and/or how to programmaticall y loop through web forms

      Hi Tim,

      Sort of ... we have a product that is in an Access database and we have
      upsized most of the forms and code to VB.NET (ADO.NET, Oracle/SQL server). We
      have a feature in the Access version that allows users to validate data on
      various forms in the system through a wizard. In order for users to be able
      to easily create their own data validation on data input forms, we have a
      wizard that allows them to view the "chosen" form, view the data fields and
      create the validation for the fields. We need all our form information in a
      table to allow this feature (in our product).

      What I am trying to do is to programmaticall y extract the form information
      and save them to the table without having to add additional lines of code to
      every form.

      I hope this information helps.
      Thanks,
      Alice


      "Tim" wrote:
      [color=blue]
      > Are you upsizing your Access app to a web app?
      >
      > "ALthePal" wrote:
      >[color=green]
      > > Hi,
      > >
      > > I'm not sure if we are able to or even how to loop through the web forms in
      > > a VB.NET project during design time. In MSAccess we are able to go through
      > > the database -> forms collection and loop through all the forms in a database
      > > and pull information about the form (controls and properties). We would need
      > > to do the same in our VB.NET project; loop through the project and get the
      > > web form's control and property information programmaticall y. The information
      > > needs to get populated into a table in the database.
      > >
      > > If anyone has any ideas that would be most helpful.
      > >
      > > Thanks,[/color][/color]

      Comment

      • Tim

        #4
        RE: able to and/or how to programmaticall y loop through web forms

        Alice,

        I think I am almost there in understanding what you are try to do in your
        app. Just have few more questions.

        Are you already able to save the validation rules after the user defines them?

        If so, are you trying to implement code that applies the rules created by
        the users to each form as they are activated without having to put the code
        in each form?

        Do you use menu items to access each of the forms?


        "ALthePal" wrote:
        [color=blue]
        > Hi Tim,
        >
        > Sort of ... we have a product that is in an Access database and we have
        > upsized most of the forms and code to VB.NET (ADO.NET, Oracle/SQL server). We
        > have a feature in the Access version that allows users to validate data on
        > various forms in the system through a wizard. In order for users to be able
        > to easily create their own data validation on data input forms, we have a
        > wizard that allows them to view the "chosen" form, view the data fields and
        > create the validation for the fields. We need all our form information in a
        > table to allow this feature (in our product).
        >
        > What I am trying to do is to programmaticall y extract the form information
        > and save them to the table without having to add additional lines of code to
        > every form.
        >
        > I hope this information helps.
        > Thanks,
        > Alice
        >
        >
        > "Tim" wrote:
        >[color=green]
        > > Are you upsizing your Access app to a web app?
        > >
        > > "ALthePal" wrote:
        > >[color=darkred]
        > > > Hi,
        > > >
        > > > I'm not sure if we are able to or even how to loop through the web forms in
        > > > a VB.NET project during design time. In MSAccess we are able to go through
        > > > the database -> forms collection and loop through all the forms in a database
        > > > and pull information about the form (controls and properties). We would need
        > > > to do the same in our VB.NET project; loop through the project and get the
        > > > web form's control and property information programmaticall y. The information
        > > > needs to get populated into a table in the database.
        > > >
        > > > If anyone has any ideas that would be most helpful.
        > > >
        > > > Thanks,[/color][/color][/color]

        Comment

        • Angelos Karantzalis

          #5
          Re: able to and/or how to programmaticall y loop through web forms

          Hi Al,

          I see more-or-less what you're trying to do. Unfortunately, I don't
          think that you can duplicate the Access behavior in a Web Project, mainly
          because there is no out-of-the-box "container" ( like .. Access ) that
          contains a list of forms.

          The only similar entity I can think of for a web project would be the
          actual virtual directory or web site in IIS. you can get programmatic access
          to IIS through WMI using .NET ( I think ), but you can also do that using
          scripting, check out the IIS Admin scripts under webroot on your IIS
          installation. However, at best I think you'd only be able to get a list of
          "files" or "forms" under the site root & sub-folders, without having the
          distinction between data entry forms & other sorts of pages there ...

          If I could recommend another approach ? If you've already invested time in
          ASP.NET web Forms code it will seem a lot of hussle, but ... it's the only
          thing I can think of off the top of my head:

          You could generate the data entry forms dynamically. For instance, we have
          defined data entry forms in xml here, and use that to generate an HTML
          interface through XSL. Then, as the form is posted, all forms go to the same
          ..aspx ( or HttpHandler ), which uses the form xml to instantiate the
          required validators with the needed parameters, validate the form data, and
          do whatever if validation is successful, or return the user to the form
          indicating the errors.

          Our form description looks something like this:

          <?xml version="1.0" encoding="utf-8" ?>
          <forms>
          <form id="Register" xsl-file="form.xsl" handler-class="">
          <fields>
          <field id="uname" type="TextField ">
          <validators>
          <validator
          class="System.W eb.UI.WebContro ls.RequiredFiel dValidator">
          <properties>
          <property name="InitialVa lue" value=""/>
          <property name="ErrorMess age" value="Please fill-in the
          required field: Password"/>
          </properties>
          </validator>
          </validators>
          </field>
          </fields>
          </form>
          </forms>

          ... i know, it's kinda bloated, but let's leave that aside for a minute -
          we're working on that :D

          If you use this xml-based approach, you could work on the forms, fields &
          validators, because you have all the forms defined in the xml, which is
          something you can work with in a much simpler way. It wouldn't be hard to
          create some sort of UI for Form creation & editing.

          It all boils down in the impementation of the engine, the two aspx pages
          that will be used for displaying the form, and processing the input.
          Something like this:



          &

          http://localhost/dynforms/ProcessFor...uname=whatever (
          assuming that you're using GET, but using POST doesn't really change
          anything in the implementation. I do it so that I can see that it actually
          passes the parameters correctly,and I'll switch to POST afterwards ... )

          The displaying part is easy. All you need to do is create some simple XSL to
          generate an HTML form from the xml, and just write that out directly to your
          Response output stream.

          the processing part is a bit trickier - mainly because ASP.NET validators
          are actually UI components as far as ASP.NET is concerned, so you'll have to
          write some trivial code to add them onto the page, despite the fact that
          nothing will be displayed ... :? .. it's one of those things with ASP.NET I
          guess ...

          ...but in the end of all this, you'll have an excellent(?) way of producing
          data entry forms, at the same time being able to edit them, add/remove
          fields, validators and end-point behavior (save to DB ? e-mail the form
          contents ? both ? whatever else ? ) completely dynamically.

          It's worked wonders for me so far, being able to add validating forms to a
          site with a single xml description ( I should point out though that you only
          get server-side validation this way, otherwise you'll really have to do some
          XSL wonders to generate & add the client-side validation Javascript .. )

          If you do decide to follow this approach however, bear in mind that you'd
          better create aome class hierarchy & parse the xml inot objects if you've
          got too many forms on your project. Keeping an xml file of 200K in memory is
          a bit of an overhead for your server. The same xml in object form is much
          smaller in memory size.

          Well, that's what I think :] hope this helped a bit cos' it took me 10' to
          write :D

          Angel
          O:]

          "ALthePal" <ALthePal@discu ssions.microsof t.com> wrote in message
          news:A81D48E5-BD46-471C-BE69-CD6F91A7275C@mi crosoft.com...[color=blue]
          > Hi Tim,
          >
          > Sort of ... we have a product that is in an Access database and we have
          > upsized most of the forms and code to VB.NET (ADO.NET, Oracle/SQL server).[/color]
          We[color=blue]
          > have a feature in the Access version that allows users to validate data on
          > various forms in the system through a wizard. In order for users to be[/color]
          able[color=blue]
          > to easily create their own data validation on data input forms, we have a
          > wizard that allows them to view the "chosen" form, view the data fields[/color]
          and[color=blue]
          > create the validation for the fields. We need all our form information in[/color]
          a[color=blue]
          > table to allow this feature (in our product).
          >
          > What I am trying to do is to programmaticall y extract the form information
          > and save them to the table without having to add additional lines of code[/color]
          to[color=blue]
          > every form.
          >
          > I hope this information helps.
          > Thanks,
          > Alice
          >
          >
          > "Tim" wrote:
          >[color=green]
          > > Are you upsizing your Access app to a web app?
          > >
          > > "ALthePal" wrote:
          > >[color=darkred]
          > > > Hi,
          > > >
          > > > I'm not sure if we are able to or even how to loop through the web[/color][/color][/color]
          forms in[color=blue][color=green][color=darkred]
          > > > a VB.NET project during design time. In MSAccess we are able to go[/color][/color][/color]
          through[color=blue][color=green][color=darkred]
          > > > the database -> forms collection and loop through all the forms in a[/color][/color][/color]
          database[color=blue][color=green][color=darkred]
          > > > and pull information about the form (controls and properties). We[/color][/color][/color]
          would need[color=blue][color=green][color=darkred]
          > > > to do the same in our VB.NET project; loop through the project and get[/color][/color][/color]
          the[color=blue][color=green][color=darkred]
          > > > web form's control and property information programmaticall y. The[/color][/color][/color]
          information[color=blue][color=green][color=darkred]
          > > > needs to get populated into a table in the database.
          > > >
          > > > If anyone has any ideas that would be most helpful.
          > > >
          > > > Thanks,[/color][/color][/color]


          Comment

          • ALthePal

            #6
            RE: able to and/or how to programmaticall y loop through web forms

            Hi Tim,

            sorry for the late reply ... but yes we are saving the validation rules
            after the user defines them. When they open the form again we check the
            validation rule, and run the expected outcome for the rule (hide fields,
            messages to user etc.).

            Yes, we are trying to run the validation as the web form is called without
            having to put code behind each form ... way to many forms.

            I'm not sure what you mean by menu items to access the forms ... the main
            form is embedded in a frameset and in a frame beside the main form resides
            the navigation tree. We are basically trying to recreate the desktop version
            in a web format ... getting to be tricky.

            Thanks in advance for your help,
            Alice

            "Tim" wrote:
            [color=blue]
            > Alice,
            >
            > I think I am almost there in understanding what you are try to do in your
            > app. Just have few more questions.
            >
            > Are you already able to save the validation rules after the user defines them?
            >
            > If so, are you trying to implement code that applies the rules created by
            > the users to each form as they are activated without having to put the code
            > in each form?
            >
            > Do you use menu items to access each of the forms?
            >
            >
            > "ALthePal" wrote:
            >[color=green]
            > > Hi Tim,
            > >
            > > Sort of ... we have a product that is in an Access database and we have
            > > upsized most of the forms and code to VB.NET (ADO.NET, Oracle/SQL server). We
            > > have a feature in the Access version that allows users to validate data on
            > > various forms in the system through a wizard. In order for users to be able
            > > to easily create their own data validation on data input forms, we have a
            > > wizard that allows them to view the "chosen" form, view the data fields and
            > > create the validation for the fields. We need all our form information in a
            > > table to allow this feature (in our product).
            > >
            > > What I am trying to do is to programmaticall y extract the form information
            > > and save them to the table without having to add additional lines of code to
            > > every form.
            > >
            > > I hope this information helps.
            > > Thanks,
            > > Alice
            > >
            > >
            > > "Tim" wrote:
            > >[color=darkred]
            > > > Are you upsizing your Access app to a web app?
            > > >
            > > > "ALthePal" wrote:
            > > >
            > > > > Hi,
            > > > >
            > > > > I'm not sure if we are able to or even how to loop through the web forms in
            > > > > a VB.NET project during design time. In MSAccess we are able to go through
            > > > > the database -> forms collection and loop through all the forms in a database
            > > > > and pull information about the form (controls and properties). We would need
            > > > > to do the same in our VB.NET project; loop through the project and get the
            > > > > web form's control and property information programmaticall y. The information
            > > > > needs to get populated into a table in the database.
            > > > >
            > > > > If anyone has any ideas that would be most helpful.
            > > > >
            > > > > Thanks,[/color][/color][/color]

            Comment

            • ALthePal

              #7
              Re: able to and/or how to programmaticall y loop through web forms

              Hi Angel,

              Thanks for you help.

              I like the idea of dynamically creating the forms but because we are trying
              to duplicate the look and feel of an existing desktop version ... it'll be
              hard to do with all the style sheets and such.

              I don't have as much experience with ASP as you do so most of what you have
              written has just gone over my head ... sorry. Plus all the time you spent in
              responding to me ... thanks. I really appreciate it ... I"ll have to pass
              this on to my co-workers that will be able to dumb down the information here
              for me ;)

              Thanks so much for your help and time,
              Alice

              "Angelos Karantzalis" wrote:
              [color=blue]
              > Hi Al,
              >
              > I see more-or-less what you're trying to do. Unfortunately, I don't
              > think that you can duplicate the Access behavior in a Web Project, mainly
              > because there is no out-of-the-box "container" ( like .. Access ) that
              > contains a list of forms.
              >
              > The only similar entity I can think of for a web project would be the
              > actual virtual directory or web site in IIS. you can get programmatic access
              > to IIS through WMI using .NET ( I think ), but you can also do that using
              > scripting, check out the IIS Admin scripts under webroot on your IIS
              > installation. However, at best I think you'd only be able to get a list of
              > "files" or "forms" under the site root & sub-folders, without having the
              > distinction between data entry forms & other sorts of pages there ...
              >
              > If I could recommend another approach ? If you've already invested time in
              > ASP.NET web Forms code it will seem a lot of hussle, but ... it's the only
              > thing I can think of off the top of my head:
              >
              > You could generate the data entry forms dynamically. For instance, we have
              > defined data entry forms in xml here, and use that to generate an HTML
              > interface through XSL. Then, as the form is posted, all forms go to the same
              > ..aspx ( or HttpHandler ), which uses the form xml to instantiate the
              > required validators with the needed parameters, validate the form data, and
              > do whatever if validation is successful, or return the user to the form
              > indicating the errors.
              >
              > Our form description looks something like this:
              >
              > <?xml version="1.0" encoding="utf-8" ?>
              > <forms>
              > <form id="Register" xsl-file="form.xsl" handler-class="">
              > <fields>
              > <field id="uname" type="TextField ">
              > <validators>
              > <validator
              > class="System.W eb.UI.WebContro ls.RequiredFiel dValidator">
              > <properties>
              > <property name="InitialVa lue" value=""/>
              > <property name="ErrorMess age" value="Please fill-in the
              > required field: Password"/>
              > </properties>
              > </validator>
              > </validators>
              > </field>
              > </fields>
              > </form>
              > </forms>
              >
              > ... i know, it's kinda bloated, but let's leave that aside for a minute -
              > we're working on that :D
              >
              > If you use this xml-based approach, you could work on the forms, fields &
              > validators, because you have all the forms defined in the xml, which is
              > something you can work with in a much simpler way. It wouldn't be hard to
              > create some sort of UI for Form creation & editing.
              >
              > It all boils down in the impementation of the engine, the two aspx pages
              > that will be used for displaying the form, and processing the input.
              > Something like this:
              >
              > http://localhost/dynforms/DisplayFor...?form=Register
              >
              > &
              >
              > http://localhost/dynforms/ProcessFor...uname=whatever (
              > assuming that you're using GET, but using POST doesn't really change
              > anything in the implementation. I do it so that I can see that it actually
              > passes the parameters correctly,and I'll switch to POST afterwards ... )
              >
              > The displaying part is easy. All you need to do is create some simple XSL to
              > generate an HTML form from the xml, and just write that out directly to your
              > Response output stream.
              >
              > the processing part is a bit trickier - mainly because ASP.NET validators
              > are actually UI components as far as ASP.NET is concerned, so you'll have to
              > write some trivial code to add them onto the page, despite the fact that
              > nothing will be displayed ... :? .. it's one of those things with ASP.NET I
              > guess ...
              >
              > ...but in the end of all this, you'll have an excellent(?) way of producing
              > data entry forms, at the same time being able to edit them, add/remove
              > fields, validators and end-point behavior (save to DB ? e-mail the form
              > contents ? both ? whatever else ? ) completely dynamically.
              >
              > It's worked wonders for me so far, being able to add validating forms to a
              > site with a single xml description ( I should point out though that you only
              > get server-side validation this way, otherwise you'll really have to do some
              > XSL wonders to generate & add the client-side validation Javascript .. )
              >
              > If you do decide to follow this approach however, bear in mind that you'd
              > better create aome class hierarchy & parse the xml inot objects if you've
              > got too many forms on your project. Keeping an xml file of 200K in memory is
              > a bit of an overhead for your server. The same xml in object form is much
              > smaller in memory size.
              >
              > Well, that's what I think :] hope this helped a bit cos' it took me 10' to
              > write :D
              >
              > Angel
              > O:]
              >
              > "ALthePal" <ALthePal@discu ssions.microsof t.com> wrote in message
              > news:A81D48E5-BD46-471C-BE69-CD6F91A7275C@mi crosoft.com...[color=green]
              > > Hi Tim,
              > >
              > > Sort of ... we have a product that is in an Access database and we have
              > > upsized most of the forms and code to VB.NET (ADO.NET, Oracle/SQL server).[/color]
              > We[color=green]
              > > have a feature in the Access version that allows users to validate data on
              > > various forms in the system through a wizard. In order for users to be[/color]
              > able[color=green]
              > > to easily create their own data validation on data input forms, we have a
              > > wizard that allows them to view the "chosen" form, view the data fields[/color]
              > and[color=green]
              > > create the validation for the fields. We need all our form information in[/color]
              > a[color=green]
              > > table to allow this feature (in our product).
              > >
              > > What I am trying to do is to programmaticall y extract the form information
              > > and save them to the table without having to add additional lines of code[/color]
              > to[color=green]
              > > every form.
              > >
              > > I hope this information helps.
              > > Thanks,
              > > Alice
              > >
              > >
              > > "Tim" wrote:
              > >[color=darkred]
              > > > Are you upsizing your Access app to a web app?
              > > >
              > > > "ALthePal" wrote:
              > > >
              > > > > Hi,
              > > > >
              > > > > I'm not sure if we are able to or even how to loop through the web[/color][/color]
              > forms in[color=green][color=darkred]
              > > > > a VB.NET project during design time. In MSAccess we are able to go[/color][/color]
              > through[color=green][color=darkred]
              > > > > the database -> forms collection and loop through all the forms in a[/color][/color]
              > database[color=green][color=darkred]
              > > > > and pull information about the form (controls and properties). We[/color][/color]
              > would need[color=green][color=darkred]
              > > > > to do the same in our VB.NET project; loop through the project and get[/color][/color]
              > the[color=green][color=darkred]
              > > > > web form's control and property information programmaticall y. The[/color][/color]
              > information[color=green][color=darkred]
              > > > > needs to get populated into a table in the database.
              > > > >
              > > > > If anyone has any ideas that would be most helpful.
              > > > >
              > > > > Thanks,[/color][/color]
              >
              >
              >[/color]

              Comment

              Working...