Form Tag of Current Page?

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Form Tag of Current Page?



    From my codebehind, I am trying to get an object reference to the
    current form, so I can perform a FindControl and work with one of the
    child controls.

    My problem is that I never know the name of the control. How to find
    that (using Reflection?)?

    Thanks.

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    sc Guest

  2. Similar Questions and Discussions

    1. adding current date into Access using DW form
      I've looked all over this forum finding similar solutions but not exactly what I'm looking for. Relatively simple. My Access 2002 database has a...
    2. Get the name of the current page
      How do I get the name of the current .aspx page using vb.net in asp.net? TIA, Steve Wofford www.IntraRELY.com
    3. redirect to another page based on text in the URL of the current page
      Hi JPElectron, You were looking good until you got to the code. You're trying to use client-side code for your redirects, when you should be...
    4. Send current record data in one form to another and print?
      On Tue, 15 Jul 2003 10:09:12 -0700, "Seddon Acaster" <seddonandjulia@acas.demon.co.uk> wrote: Clarification: The Form doesn't contain any...
    5. Autofill current date in field on form
      Need a field to autofill the current date on a form. The user will be filling in one field with a control number and the date field will be the...
  3. #2

    Default Re: Form Tag of Current Page?

    Hi, sc:

    Well, one not-so-robust way of finding the form control for a page is to
    iterate through the page's controls until you find one that is of type
    HtmlForm. Some sample VB code follows.

    -------------
    ' Iterate the Page's controls for the HtmlForm
    dim MyForm as HtmlForm
    for each control as Control in Page.Controls
    if TypeOf control is HtmlForm then
    MyForm = CType(control, HtmlForm)
    exit for
    end if
    next

    ' Test for a match
    ' *** This really isn't necessary since there has to be a match for server
    other controls to even work
    if not MyForm is Nothing then
    ' Do something with the form control
    end if
    -------------

    This isn't ideal, I know. However, considering the page control tree, it
    hasn't taken very long at all to find the form control in my tests.

    Hope this helps,
    Matt


    Matt Sollars Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139