dynamic forms

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

    #1

    dynamic forms

    I am developing a user control that builds dynamic forms
    taken from a string
    (str_output).

    I have a string such as <table><tr><td> <asp:checkbox
    id="chk1"
    runat="server" /><asp:checkbo x id="chk2"
    runat="server" /></td></tr></table>

    Note this is generated from by the call
    obj_dbMediaFile .GetMedia (this is a
    component I have written)


    I have a code behind script which as the following
    structure:

    sub page_load

    if not page.IsPostBack then
    CreateContent()
    end if

    end sub


    The create content function puts the string above into a
    label called
    output:


    Public sub CreateContent
    dim obj_dbMediaFile as dbMediaFile
    str_output =
    obj_dbMediaFile .GetMedia
    (1,int_currentR ecord.value,int _PageSize)

    dim obj_control as new Control
    obj_control = ParseControl(st r_output)
    output.Controls .Add(obj_contro l)

    end sub

    On running the script the form elements in the string are
    correctly
    rendered. When a normal button called btn_delete
    (hardcoded into the ascx
    file) is pressed the function btn_delete_clic k is called.


    Public sub btn_delete_Clic k(Sender as object ,E as
    system.EventArg s )
    CreateContent()
    IterateThroughC ontrols(me)
    end sub


    This calls the form creation function and then calls the
    function
    IterateThroughC ontrols(me).


    Sub IterateThroughC ontrols(parent as Control )

    Dim obj_control as Control

    for each obj_Control in parent.Controls

    if typeof obj_Control is checkbox then

    'This would suggest that at this point the obj_control
    has not been updated

    if CType(obj_contr ol, checkbox).check ed = true then

    testing.Text += "true"

    else
    testing.Text += "false"
    end if
    end if

    if obj_Control.Con trols.Count > 0 then
    IterateThroughC ontrols(obj_Con trol)

    end if
    next

    end sub


    This function finds all the rendered checkboxs. This
    works fine, whoever it
    doesn't seem to be able to access there value (always
    sets the label test =
    false(s)).


    I have noticed that if I try to access the value of the
    label named output
    (which houses the rendered form elements and is set in
    the CreateContent()
    function) and place it into another hardcoded label, the
    value is empty even
    thogh the content has been rendered to the screen.

    Any ideas what the problem is?


Working...