Professional Web Applications Themes

Getting values entered into (dynamicly loaded control) - ASP.NET Building Controls

I've dynamicly loaded user control (.ascx file) into my page via Page.LoadControl() method. The control has been added to Controls collection of some TableCell (named dynamicCtlPlaceholder). The control appears in the desired location. The control allows to enter two strings: name and surname. I would like to get data, that user entered into the control (two textboxes inside the control) upon postback. how can I get it ? When I iterate through the dynamicCtlPlaceholder's Controls property, there is no my control. The runtime has not recreated it upon postback. How can I get the values ? Thanks for help Michal ...

  1. #1

    Default Getting values entered into (dynamicly loaded control)

    I've dynamicly loaded user control (.ascx file) into my page via
    Page.LoadControl() method. The control has been added to Controls collection
    of some TableCell (named dynamicCtlPlaceholder). The control appears in the
    desired location. The control allows to enter two strings: name and surname.

    I would like to get data, that user entered into the control (two textboxes
    inside the control) upon postback. how can I get it ?
    When I iterate through the dynamicCtlPlaceholder's Controls property, there
    is no my control. The runtime has not recreated it upon postback.

    How can I get the values ?

    Thanks for help
    Michal Januszczyk


    Micha³ Januszczyk Guest

  2. #2

    Default Re: Getting values entered into (dynamicly loaded control)

    Assign ID for your control.
    And do like this:

    Page.FindControl(ID)

    "Micha³ Januszczyk" <michal_januszczyk_N0_SPAM_hotmail.com> wrote in
    message news:OY28FBMJFHA.2704tk2msftngp13.phx.gbl...
    > I've dynamicly loaded user control (.ascx file) into my page via
    > Page.LoadControl() method. The control has been added to Controls
    > collection of some TableCell (named dynamicCtlPlaceholder). The control
    > appears in the desired location. The control allows to enter two strings:
    > name and surname.
    >
    > I would like to get data, that user entered into the control (two
    > textboxes inside the control) upon postback. how can I get it ?
    > When I iterate through the dynamicCtlPlaceholder's Controls property,
    > there is no my control. The runtime has not recreated it upon postback.
    >
    > How can I get the values ?
    >
    > Thanks for help
    > Michal Januszczyk
    >

    Mantas Miliukas Guest

  3. #3

    Default Re: Getting values entered into (dynamicly loaded control)

    "Mantas Miliukas" <mantasraktas.net> wrote:
    > Assign ID for your control.
    > And do like this:
    >
    > Page.FindControl(ID)
    >
    The problem lays more deep down than I thought.

    I had not mentioned previously that the dynamicly loaded control is
    constructed
    each time it is loaded. Its partial controls are dynamically created, and so
    the values
    are lost. Besides that, the control was not loaded each time the page was
    reloaded.

    But, ok. Now the control is reloaded each time the page is posted back.
    Additionally
    I have added a "static" (not dynamically created) Control (also TextBox).
    This Textbox
    preserves its value, but the ones that are generated dynamically do not. Is
    there any way
    to make them behave the same as the "static" one control ?

    Thanks
    Micha³ Januszczyk


    Micha³ Januszczyk Guest

  4. #4

    Default Re: Getting values entered into (dynamicly loaded control)

    more details:

    It seems that dynamically generated IDs for the controls caused that the
    values have not been retained. The IDs were generated (and assigned to
    controls) so as to allow dynamically created validators to watch the very
    controls. Validators unfortunately cannot be told to watch specified object,
    but it accepts only textual ID of the control (ControlToValidate property)

    Regards,
    Micha³ Januszczyk


    Micha³ Januszczyk Guest

  5. #5

    Default Re: Getting values entered into (dynamicly loaded control)

    When are you performing the search?
    Basically you can do it by overriding or attaching to "OnLoad" method.

    "Micha³ Januszczyk" <michal_januszczyk_N0_SPAM_hotmail.com> wrote in
    message news:OY28FBMJFHA.2704tk2msftngp13.phx.gbl...
    > I've dynamicly loaded user control (.ascx file) into my page via
    > Page.LoadControl() method. The control has been added to Controls
    > collection of some TableCell (named dynamicCtlPlaceholder). The control
    > appears in the desired location. The control allows to enter two strings:
    > name and surname.
    >
    > I would like to get data, that user entered into the control (two
    > textboxes inside the control) upon postback. how can I get it ?
    > When I iterate through the dynamicCtlPlaceholder's Controls property,
    > there is no my control. The runtime has not recreated it upon postback.
    >
    > How can I get the values ?
    >
    > Thanks for help
    > Michal Januszczyk
    >

    Mantas Miliukas Guest

Similar Threads

  1. How do I validate the values entered for custom control properties?
    By Nathan Sokalski in forum ASP.NET Building Controls
    Replies: 2
    Last Post: July 21st, 06:34 PM
  2. Replies: 1
    Last Post: April 26th, 06:58 AM
  3. How to access values entered in User control in the main page.
    By vineetbatta in forum ASP.NET Building Controls
    Replies: 1
    Last Post: November 7th, 01:28 AM
  4. Dynamicly loaded User Control events in a Placeholder
    By MikeM in forum ASP.NET Building Controls
    Replies: 1
    Last Post: April 12th, 07:31 PM
  5. How to add WebUser control dynamicly to the FORM.
    By DesignerX in forum ASP.NET General
    Replies: 0
    Last Post: July 21st, 10:25 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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