dynamic forms

R

Rick

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:checkbox 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_currentRecord.value,int_PageSize)

dim obj_control as new Control
obj_control = ParseControl(str_output)
output.Controls.Add(obj_control)

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_click is called.


Public sub btn_delete_Click(Sender as object ,E as
system.EventArgs )
CreateContent()
IterateThroughControls(me)
end sub


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


Sub IterateThroughControls(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_control, checkbox).checked = true then

testing.Text += "true"

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

if obj_Control.Controls.Count > 0 then
IterateThroughControls(obj_Control)

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,083
Messages
2,570,591
Members
47,212
Latest member
RobynWiley

Latest Threads

Top