Rendering Server Controls in literal text

G

Guest

Hello All:

I am trying to dynamically populate a web page with literal content and
controls (textboxes and checkboxes (and eventually two buttons - the buttons
do not appear in the code yet). I read an xml file and, using the values
retrieved from it, determine what text should be displayed and which controls
should be rendered and - most importantly - where those controls should be
rendered.

The ultimate goal is to have some text followed by a control that will
capture the users response and post it back to the server. For example the
page might show:

Please enter the dollar amount: [textbox goes here].
Was this an accident? [checkbox for yes] Yes [checkbox for no] No

The problem is that all of the controls are rendered at the top of the page
and all of the text renders after the closing html tag. I don't know why
this is and I don't know enough about the Render method to speak
intelligently about it. I hope that I have explained clearly what I am
trying to do. If not please let me know.

The code is here:

Structure DynamicControl
Dim Type As String
Dim FieldType As String
Dim Name As String
Dim FieldName As String
Dim Size As String
Dim MaxLength As String
Dim EntryType As String
End Structure

Private doc As XmlDocument
Private Lines As XmlNodeList
Private ReqData As XmlNodeList

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Response.BufferOutput = True
Dim Line As XmlNode
Dim ChildNode As XmlNode
Dim DynamicEntry As XmlNode

output = New HtmlTextWriter(txtWtr)

doc = New XmlDocument
doc.Load("C:\SampleForm.xml")

Lines = doc.GetElementsByTagName("Line")
ReqData = doc.GetElementsByTagName("Data")

For Each Line In Lines
If Line.HasChildNodes Then
For Each ChildNode In Line.ChildNodes
Dim attrList As XmlAttributeCollection =
ChildNode.Attributes
If Not (attrList Is Nothing) Then
Dim DynCtl As DynamicControl =
ParseDynamicCtrlData(attrList.GetNamedItem("id").Value)

Select Case DynCtl.FieldType.ToLower
Case "checkbox"
Dim c As CheckBox = New CheckBox
c.ID = attrList.GetNamedItem("id").Value
c.Text = DynCtl.Name
Me.Controls(1).Controls.Add(c)

Case "text"
Dim t As TextBox = New TextBox
t.ID = attrList.GetNamedItem("id").Value
t.MaxLength = CType(DynCtl.MaxLength, Integer)
t.Text = DynCtl.Name
Me.Controls(1).Controls.Add(t)

End Select
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
End Sub

Private Function ParseDynamicCtrlData(ByVal id As String) As
DynamicControl
Dim DataNode As XmlNode
Dim dc As DynamicControl

For Each DataNode In ReqData
If String.Compare(DataNode.Attributes("name").Value, id) = 0 Then
dc.FieldType = DataNode.Attributes("fieldtype").Value
If dc.FieldType.ToLower = "text" Then
If String.Compare(DataNode.Attributes("type").Value,
"merge") <> 0 Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value
dc.Size = DataNode.Attributes("size").Value
dc.MaxLength = DataNode.Attributes("maxlength").Value
End If

ElseIf dc.FieldType.ToLower = "checkbox" Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value

End If
Exit For
End If
Next

Return dc
End Function

The XML is here:

<Form>
<Content>
<Line><Dynamic type="text" id="DateField"/></Line>
<Line/>
<Line><Dynamic type="text" id="CustomAddress1"/></Line>
<Line><Dynamic type="text" id="CustomAddress2"/></Line>
<Line><Dynamic type="text" id="CustomAddress3"/></Line>
<Line><Dynamic type="text" id="CustomAddress4"/></Line>
<Line/>
<Line/>
<Line>RE: Your File #: <Dynamic type="text" id="YourFile"/></Line>
<Line> Your Insured: <Dynamic type="text" id="YourInsured"/></Line>
<Line> Our File #: <Dynamic type="text" id="OurFile"/></Line>
<Line> Our Insured: <Dynamic type="text" id="OurInsured"/></Line>
<Line> Date of Loss: <Dynamic type="text" id="DateOfLoss"/></Line>
<Line/>
<Line>We are asking you to please complete the following with regard to
your No-Fault file on the above mentioned insured.</Line>
<Line/>
<Line>Medical paid: <Dynamic type="text" id="MedicalPaid"/></Line>
<Line>Wage Loss paid: <Dynamic type="text" id="WageLossPaid"/></Line>
<Line>Essential Services paid: <Dynamic type="text"
id="EssentialServicesPaid"/></Line>
<Line>Advise if threshold passed: <Dynamic
type="checkbox" id="AdviseThresholdYes"/> Yes <Dynamic type="checkbox"
id="AdviseThresholdNo"/> No</Line>
<Line>Have you conducted an IME at this time? <Dynamic
type="checkbox" id="ConductedIMEYes"/> Yes <Dynamic
type="checkbox" id="ConductedIMENo"/> No</Line>
<Line>If not, do you contemplate scheduling one? <Dynamic
type="checkbox" id="ContemplateSchedulingYes"/> Yes <Dynamic
type="checkbox" id="ContemplateSchedulingNo"/> No</Line>
<Line>Nature of injury <Dynamic type="text" id="NatureOfInjury"/></Line>
<Line>We thank you for your cooperation and are enclosing a return envelope
for your convenience.</Line>
<Line/>
<Line>Sincerely,</Line>
<Line/>
<Line/>
<Line/>
<Line/>
<Line><Dynamic type="text" id="AdjusterName"/></Line>
<Line><Dynamic type="text" id="AdjusterPhone"/></Line>
<Line/>
<Line>Claims Department</Line>
<Line/>
<Line/>
<Line>WB-204 (12-99)</Line>
</Content>
<RequiredData>
<Data fieldtype="NowDate" name="DateField"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress1"
fieldname="CustomAddress1" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress2"
fieldname="CustomAddress2" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress3"
fieldname="CustomAddress3" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress4"
fieldname="CustomAddress4" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="YourFile" fieldname="YourFile"
size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="YourInsured"
fieldname="YourInsured" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="OurFile" fieldname="OurFile"
size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="OurInsured"
fieldname="OurInsured" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="DateOfLoss"
fieldname="DateOfLoss" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="MedicalPaid"
fieldname="MedicalPaid" size="30" maxlength="20" entrytype="Numeric"/>
<Data type="Entry" fieldtype="Text" name="WageLossPaid"
fieldname="WageLossPaid" size="30" maxlength="20" entrytype="Numeric"/>
<Data type="Entry" fieldtype="Text" name="EssentialServicesPaid"
fieldname="EssentialServicesPaid" size="30" maxlength="20"
entrytype="Numeric"/>
<Data type="Entry" fieldtype="Checkbox" name="AdviseThresholdYes"
fieldname="AdviseThresholdYes"/>
<Data type="Entry" fieldtype="Checkbox" name="AdviseThresholdNo"
fieldname="AdviseThresholdNo"/>
<Data type="Entry" fieldtype="Checkbox" name="ConductedIMEYes"
fieldname="ConductedIMEYes"/>
<Data type="Entry" fieldtype="Checkbox" name="ConductedIMENo"
fieldname="ConductedIMENo"/>
<Data type="Entry" fieldtype="Checkbox" name="ContemplateSchedulingYes"
fieldname="ContemplateSchedulingYes"/>
<Data type="Entry" fieldtype="Checkbox" name="ContemplateSchedulingNo"
fieldname="ContemplateSchedulingNo"/>
<Data type="Entry" fieldtype="Text" name="NatureOfInjury"
fieldname="NatureOfInjury" size="30" maxlength="30"/>
<Data type="Merge" fieldtype="Text" name="AdjusterName"
fieldname="AdjusterName" size="30" maxlength="30"/>
<Data type="Merge" fieldtype="Text" name="AdjusterPhone"
fieldname="AdjusterPhone" size="30" maxlength="30"/>
</RequiredData>
</Form>

Any help would be greatly appreciated.
 
G

Guest

if I read it right you are simply adding the controls to the page, but not
specifying where.
You may want to look at the placeholder to use to add your controls to.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



Joe said:
Hello All:

I am trying to dynamically populate a web page with literal content and
controls (textboxes and checkboxes (and eventually two buttons - the buttons
do not appear in the code yet). I read an xml file and, using the values
retrieved from it, determine what text should be displayed and which controls
should be rendered and - most importantly - where those controls should be
rendered.

The ultimate goal is to have some text followed by a control that will
capture the users response and post it back to the server. For example the
page might show:

Please enter the dollar amount: [textbox goes here].
Was this an accident? [checkbox for yes] Yes [checkbox for no] No

The problem is that all of the controls are rendered at the top of the page
and all of the text renders after the closing html tag. I don't know why
this is and I don't know enough about the Render method to speak
intelligently about it. I hope that I have explained clearly what I am
trying to do. If not please let me know.

The code is here:

Structure DynamicControl
Dim Type As String
Dim FieldType As String
Dim Name As String
Dim FieldName As String
Dim Size As String
Dim MaxLength As String
Dim EntryType As String
End Structure

Private doc As XmlDocument
Private Lines As XmlNodeList
Private ReqData As XmlNodeList

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Response.BufferOutput = True
Dim Line As XmlNode
Dim ChildNode As XmlNode
Dim DynamicEntry As XmlNode

output = New HtmlTextWriter(txtWtr)

doc = New XmlDocument
doc.Load("C:\SampleForm.xml")

Lines = doc.GetElementsByTagName("Line")
ReqData = doc.GetElementsByTagName("Data")

For Each Line In Lines
If Line.HasChildNodes Then
For Each ChildNode In Line.ChildNodes
Dim attrList As XmlAttributeCollection =
ChildNode.Attributes
If Not (attrList Is Nothing) Then
Dim DynCtl As DynamicControl =
ParseDynamicCtrlData(attrList.GetNamedItem("id").Value)

Select Case DynCtl.FieldType.ToLower
Case "checkbox"
Dim c As CheckBox = New CheckBox
c.ID = attrList.GetNamedItem("id").Value
c.Text = DynCtl.Name
Me.Controls(1).Controls.Add(c)

Case "text"
Dim t As TextBox = New TextBox
t.ID = attrList.GetNamedItem("id").Value
t.MaxLength = CType(DynCtl.MaxLength, Integer)
t.Text = DynCtl.Name
Me.Controls(1).Controls.Add(t)

End Select
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
End Sub

Private Function ParseDynamicCtrlData(ByVal id As String) As
DynamicControl
Dim DataNode As XmlNode
Dim dc As DynamicControl

For Each DataNode In ReqData
If String.Compare(DataNode.Attributes("name").Value, id) = 0 Then
dc.FieldType = DataNode.Attributes("fieldtype").Value
If dc.FieldType.ToLower = "text" Then
If String.Compare(DataNode.Attributes("type").Value,
"merge") <> 0 Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value
dc.Size = DataNode.Attributes("size").Value
dc.MaxLength = DataNode.Attributes("maxlength").Value
End If

ElseIf dc.FieldType.ToLower = "checkbox" Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value

End If
Exit For
End If
Next

Return dc
End Function

The XML is here:

<Form>
<Content>
<Line><Dynamic type="text" id="DateField"/></Line>
<Line/>
<Line><Dynamic type="text" id="CustomAddress1"/></Line>
<Line><Dynamic type="text" id="CustomAddress2"/></Line>
<Line><Dynamic type="text" id="CustomAddress3"/></Line>
<Line><Dynamic type="text" id="CustomAddress4"/></Line>
<Line/>
<Line/>
<Line>RE: Your File #: <Dynamic type="text" id="YourFile"/></Line>
<Line> Your Insured: <Dynamic type="text" id="YourInsured"/></Line>
<Line> Our File #: <Dynamic type="text" id="OurFile"/></Line>
<Line> Our Insured: <Dynamic type="text" id="OurInsured"/></Line>
<Line> Date of Loss: <Dynamic type="text" id="DateOfLoss"/></Line>
<Line/>
<Line>We are asking you to please complete the following with regard to
your No-Fault file on the above mentioned insured.</Line>
<Line/>
<Line>Medical paid: <Dynamic type="text" id="MedicalPaid"/></Line>
<Line>Wage Loss paid: <Dynamic type="text" id="WageLossPaid"/></Line>
<Line>Essential Services paid: <Dynamic type="text"
id="EssentialServicesPaid"/></Line>
<Line>Advise if threshold passed: <Dynamic
type="checkbox" id="AdviseThresholdYes"/> Yes <Dynamic type="checkbox"
id="AdviseThresholdNo"/> No</Line>
<Line>Have you conducted an IME at this time? <Dynamic
type="checkbox" id="ConductedIMEYes"/> Yes <Dynamic
type="checkbox" id="ConductedIMENo"/> No</Line>
<Line>If not, do you contemplate scheduling one? <Dynamic
type="checkbox" id="ContemplateSchedulingYes"/> Yes <Dynamic
type="checkbox" id="ContemplateSchedulingNo"/> No</Line>
<Line>Nature of injury <Dynamic type="text" id="NatureOfInjury"/></Line>
<Line>We thank you for your cooperation and are enclosing a return envelope
for your convenience.</Line>
<Line/>
<Line>Sincerely,</Line>
<Line/>
<Line/>
<Line/>
<Line/>
<Line><Dynamic type="text" id="AdjusterName"/></Line>
<Line><Dynamic type="text" id="AdjusterPhone"/></Line>
<Line/>
<Line>Claims Department</Line>
<Line/>
<Line/>
<Line>WB-204 (12-99)</Line>
</Content>
<RequiredData>
<Data fieldtype="NowDate" name="DateField"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress1"
fieldname="CustomAddress1" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress2"
fieldname="CustomAddress2" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress3"
fieldname="CustomAddress3" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress4"
fieldname="CustomAddress4" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="YourFile" fieldname="YourFile"
size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="YourInsured"
fieldname="YourInsured" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="OurFile" fieldname="OurFile"
size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="OurInsured"
fieldname="OurInsured" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="DateOfLoss"
fieldname="DateOfLoss" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="MedicalPaid"
fieldname="MedicalPaid" size="30" maxlength="20" entrytype="Numeric"/>
<Data type="Entry" fieldtype="Text" name="WageLossPaid"
fieldname="WageLossPaid" size="30" maxlength="20" entrytype="Numeric"/>
<Data type="Entry" fieldtype="Text" name="EssentialServicesPaid"
fieldname="EssentialServicesPaid" size="30" maxlength="20"
entrytype="Numeric"/>
<Data type="Entry" fieldtype="Checkbox" name="AdviseThresholdYes"
fieldname="AdviseThresholdYes"/>
<Data type="Entry" fieldtype="Checkbox" name="AdviseThresholdNo"
fieldname="AdviseThresholdNo"/>
<Data type="Entry" fieldtype="Checkbox" name="ConductedIMEYes"
fieldname="ConductedIMEYes"/>
<Data type="Entry" fieldtype="Checkbox" name="ConductedIMENo"
fieldname="ConductedIMENo"/>
<Data type="Entry" fieldtype="Checkbox" name="ContemplateSchedulingYes"
fieldname="ContemplateSchedulingYes"/>
<Data type="Entry" fieldtype="Checkbox" name="ContemplateSchedulingNo"
fieldname="ContemplateSchedulingNo"/>
<Data type="Entry" fieldtype="Text" name="NatureOfInjury"
fieldname="NatureOfInjury" size="30" maxlength="30"/>
<Data type="Merge" fieldtype="Text" name="AdjusterName"
fieldname="AdjusterName" size="30" maxlength="30"/>
<Data type="Merge" fieldtype="Text" name="AdjusterPhone"
fieldname="AdjusterPhone" size="30" maxlength="30"/>
</RequiredData>
</Form>

Any help would be greatly appreciated.
 
G

Guest

Curt,

Since I will have no idea how many controls I am adding for a given page
(that is determined by the xml), how would I handle the ambiguity of not
knowing how many placeholders to add?

--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Curt_C said:
if I read it right you are simply adding the controls to the page, but not
specifying where.
You may want to look at the placeholder to use to add your controls to.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



Joe said:
Hello All:

I am trying to dynamically populate a web page with literal content and
controls (textboxes and checkboxes (and eventually two buttons - the buttons
do not appear in the code yet). I read an xml file and, using the values
retrieved from it, determine what text should be displayed and which controls
should be rendered and - most importantly - where those controls should be
rendered.

The ultimate goal is to have some text followed by a control that will
capture the users response and post it back to the server. For example the
page might show:

Please enter the dollar amount: [textbox goes here].
Was this an accident? [checkbox for yes] Yes [checkbox for no] No

The problem is that all of the controls are rendered at the top of the page
and all of the text renders after the closing html tag. I don't know why
this is and I don't know enough about the Render method to speak
intelligently about it. I hope that I have explained clearly what I am
trying to do. If not please let me know.

The code is here:

Structure DynamicControl
Dim Type As String
Dim FieldType As String
Dim Name As String
Dim FieldName As String
Dim Size As String
Dim MaxLength As String
Dim EntryType As String
End Structure

Private doc As XmlDocument
Private Lines As XmlNodeList
Private ReqData As XmlNodeList

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Response.BufferOutput = True
Dim Line As XmlNode
Dim ChildNode As XmlNode
Dim DynamicEntry As XmlNode

output = New HtmlTextWriter(txtWtr)

doc = New XmlDocument
doc.Load("C:\SampleForm.xml")

Lines = doc.GetElementsByTagName("Line")
ReqData = doc.GetElementsByTagName("Data")

For Each Line In Lines
If Line.HasChildNodes Then
For Each ChildNode In Line.ChildNodes
Dim attrList As XmlAttributeCollection =
ChildNode.Attributes
If Not (attrList Is Nothing) Then
Dim DynCtl As DynamicControl =
ParseDynamicCtrlData(attrList.GetNamedItem("id").Value)

Select Case DynCtl.FieldType.ToLower
Case "checkbox"
Dim c As CheckBox = New CheckBox
c.ID = attrList.GetNamedItem("id").Value
c.Text = DynCtl.Name
Me.Controls(1).Controls.Add(c)

Case "text"
Dim t As TextBox = New TextBox
t.ID = attrList.GetNamedItem("id").Value
t.MaxLength = CType(DynCtl.MaxLength, Integer)
t.Text = DynCtl.Name
Me.Controls(1).Controls.Add(t)

End Select
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
End Sub

Private Function ParseDynamicCtrlData(ByVal id As String) As
DynamicControl
Dim DataNode As XmlNode
Dim dc As DynamicControl

For Each DataNode In ReqData
If String.Compare(DataNode.Attributes("name").Value, id) = 0 Then
dc.FieldType = DataNode.Attributes("fieldtype").Value
If dc.FieldType.ToLower = "text" Then
If String.Compare(DataNode.Attributes("type").Value,
"merge") <> 0 Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value
dc.Size = DataNode.Attributes("size").Value
dc.MaxLength = DataNode.Attributes("maxlength").Value
End If

ElseIf dc.FieldType.ToLower = "checkbox" Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value

End If
Exit For
End If
Next

Return dc
End Function

The XML is here:

<Form>
<Content>
<Line><Dynamic type="text" id="DateField"/></Line>
<Line/>
<Line><Dynamic type="text" id="CustomAddress1"/></Line>
<Line><Dynamic type="text" id="CustomAddress2"/></Line>
<Line><Dynamic type="text" id="CustomAddress3"/></Line>
<Line><Dynamic type="text" id="CustomAddress4"/></Line>
<Line/>
<Line/>
<Line>RE: Your File #: <Dynamic type="text" id="YourFile"/></Line>
<Line> Your Insured: <Dynamic type="text" id="YourInsured"/></Line>
<Line> Our File #: <Dynamic type="text" id="OurFile"/></Line>
<Line> Our Insured: <Dynamic type="text" id="OurInsured"/></Line>
<Line> Date of Loss: <Dynamic type="text" id="DateOfLoss"/></Line>
<Line/>
<Line>We are asking you to please complete the following with regard to
your No-Fault file on the above mentioned insured.</Line>
<Line/>
<Line>Medical paid: <Dynamic type="text" id="MedicalPaid"/></Line>
<Line>Wage Loss paid: <Dynamic type="text" id="WageLossPaid"/></Line>
<Line>Essential Services paid: <Dynamic type="text"
id="EssentialServicesPaid"/></Line>
<Line>Advise if threshold passed: <Dynamic
type="checkbox" id="AdviseThresholdYes"/> Yes <Dynamic type="checkbox"
id="AdviseThresholdNo"/> No</Line>
<Line>Have you conducted an IME at this time? <Dynamic
type="checkbox" id="ConductedIMEYes"/> Yes <Dynamic
type="checkbox" id="ConductedIMENo"/> No</Line>
<Line>If not, do you contemplate scheduling one? <Dynamic
type="checkbox" id="ContemplateSchedulingYes"/> Yes <Dynamic
type="checkbox" id="ContemplateSchedulingNo"/> No</Line>
<Line>Nature of injury <Dynamic type="text" id="NatureOfInjury"/></Line>
<Line>We thank you for your cooperation and are enclosing a return envelope
for your convenience.</Line>
<Line/>
<Line>Sincerely,</Line>
<Line/>
<Line/>
<Line/>
<Line/>
<Line><Dynamic type="text" id="AdjusterName"/></Line>
<Line><Dynamic type="text" id="AdjusterPhone"/></Line>
<Line/>
<Line>Claims Department</Line>
<Line/>
<Line/>
<Line>WB-204 (12-99)</Line>
</Content>
<RequiredData>
<Data fieldtype="NowDate" name="DateField"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress1"
fieldname="CustomAddress1" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress2"
fieldname="CustomAddress2" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress3"
fieldname="CustomAddress3" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress4"
fieldname="CustomAddress4" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="YourFile" fieldname="YourFile"
size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="YourInsured"
fieldname="YourInsured" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="OurFile" fieldname="OurFile"
size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="OurInsured"
fieldname="OurInsured" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="DateOfLoss"
fieldname="DateOfLoss" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="MedicalPaid"
fieldname="MedicalPaid" size="30" maxlength="20" entrytype="Numeric"/>
<Data type="Entry" fieldtype="Text" name="WageLossPaid"
fieldname="WageLossPaid" size="30" maxlength="20" entrytype="Numeric"/>
<Data type="Entry" fieldtype="Text" name="EssentialServicesPaid"
fieldname="EssentialServicesPaid" size="30" maxlength="20"
entrytype="Numeric"/>
<Data type="Entry" fieldtype="Checkbox" name="AdviseThresholdYes"
fieldname="AdviseThresholdYes"/>
<Data type="Entry" fieldtype="Checkbox" name="AdviseThresholdNo"
fieldname="AdviseThresholdNo"/>
<Data type="Entry" fieldtype="Checkbox" name="ConductedIMEYes"
fieldname="ConductedIMEYes"/>
<Data type="Entry" fieldtype="Checkbox" name="ConductedIMENo"
fieldname="ConductedIMENo"/>
<Data type="Entry" fieldtype="Checkbox" name="ContemplateSchedulingYes"
fieldname="ContemplateSchedulingYes"/>
<Data type="Entry" fieldtype="Checkbox" name="ContemplateSchedulingNo"
fieldname="ContemplateSchedulingNo"/>
<Data type="Entry" fieldtype="Text" name="NatureOfInjury"
fieldname="NatureOfInjury" size="30" maxlength="30"/>
<Data type="Merge" fieldtype="Text" name="AdjusterName"
fieldname="AdjusterName" size="30" maxlength="30"/>
<Data type="Merge" fieldtype="Text" name="AdjusterPhone"
fieldname="AdjusterPhone" size="30" maxlength="30"/>
</RequiredData>
</Form>

Any help would be greatly appreciated.
 
G

Guest

Repeater perhaps.


--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



Joe said:
Curt,

Since I will have no idea how many controls I am adding for a given page
(that is determined by the xml), how would I handle the ambiguity of not
knowing how many placeholders to add?

--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Curt_C said:
if I read it right you are simply adding the controls to the page, but not
specifying where.
You may want to look at the placeholder to use to add your controls to.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



Joe said:
Hello All:

I am trying to dynamically populate a web page with literal content and
controls (textboxes and checkboxes (and eventually two buttons - the buttons
do not appear in the code yet). I read an xml file and, using the values
retrieved from it, determine what text should be displayed and which controls
should be rendered and - most importantly - where those controls should be
rendered.

The ultimate goal is to have some text followed by a control that will
capture the users response and post it back to the server. For example the
page might show:

Please enter the dollar amount: [textbox goes here].
Was this an accident? [checkbox for yes] Yes [checkbox for no] No

The problem is that all of the controls are rendered at the top of the page
and all of the text renders after the closing html tag. I don't know why
this is and I don't know enough about the Render method to speak
intelligently about it. I hope that I have explained clearly what I am
trying to do. If not please let me know.

The code is here:

Structure DynamicControl
Dim Type As String
Dim FieldType As String
Dim Name As String
Dim FieldName As String
Dim Size As String
Dim MaxLength As String
Dim EntryType As String
End Structure

Private doc As XmlDocument
Private Lines As XmlNodeList
Private ReqData As XmlNodeList

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Response.BufferOutput = True
Dim Line As XmlNode
Dim ChildNode As XmlNode
Dim DynamicEntry As XmlNode

output = New HtmlTextWriter(txtWtr)

doc = New XmlDocument
doc.Load("C:\SampleForm.xml")

Lines = doc.GetElementsByTagName("Line")
ReqData = doc.GetElementsByTagName("Data")

For Each Line In Lines
If Line.HasChildNodes Then
For Each ChildNode In Line.ChildNodes
Dim attrList As XmlAttributeCollection =
ChildNode.Attributes
If Not (attrList Is Nothing) Then
Dim DynCtl As DynamicControl =
ParseDynamicCtrlData(attrList.GetNamedItem("id").Value)

Select Case DynCtl.FieldType.ToLower
Case "checkbox"
Dim c As CheckBox = New CheckBox
c.ID = attrList.GetNamedItem("id").Value
c.Text = DynCtl.Name
Me.Controls(1).Controls.Add(c)

Case "text"
Dim t As TextBox = New TextBox
t.ID = attrList.GetNamedItem("id").Value
t.MaxLength = CType(DynCtl.MaxLength, Integer)
t.Text = DynCtl.Name
Me.Controls(1).Controls.Add(t)

End Select
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
End Sub

Private Function ParseDynamicCtrlData(ByVal id As String) As
DynamicControl
Dim DataNode As XmlNode
Dim dc As DynamicControl

For Each DataNode In ReqData
If String.Compare(DataNode.Attributes("name").Value, id) = 0 Then
dc.FieldType = DataNode.Attributes("fieldtype").Value
If dc.FieldType.ToLower = "text" Then
If String.Compare(DataNode.Attributes("type").Value,
"merge") <> 0 Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value
dc.Size = DataNode.Attributes("size").Value
dc.MaxLength = DataNode.Attributes("maxlength").Value
End If

ElseIf dc.FieldType.ToLower = "checkbox" Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value

End If
Exit For
End If
Next

Return dc
End Function

The XML is here:

<Form>
<Content>
<Line><Dynamic type="text" id="DateField"/></Line>
<Line/>
<Line><Dynamic type="text" id="CustomAddress1"/></Line>
<Line><Dynamic type="text" id="CustomAddress2"/></Line>
<Line><Dynamic type="text" id="CustomAddress3"/></Line>
<Line><Dynamic type="text" id="CustomAddress4"/></Line>
<Line/>
<Line/>
<Line>RE: Your File #: <Dynamic type="text" id="YourFile"/></Line>
<Line> Your Insured: <Dynamic type="text" id="YourInsured"/></Line>
<Line> Our File #: <Dynamic type="text" id="OurFile"/></Line>
<Line> Our Insured: <Dynamic type="text" id="OurInsured"/></Line>
<Line> Date of Loss: <Dynamic type="text" id="DateOfLoss"/></Line>
<Line/>
<Line>We are asking you to please complete the following with regard to
your No-Fault file on the above mentioned insured.</Line>
<Line/>
<Line>Medical paid: <Dynamic type="text" id="MedicalPaid"/></Line>
<Line>Wage Loss paid: <Dynamic type="text" id="WageLossPaid"/></Line>
<Line>Essential Services paid: <Dynamic type="text"
id="EssentialServicesPaid"/></Line>
<Line>Advise if threshold passed: <Dynamic
type="checkbox" id="AdviseThresholdYes"/> Yes <Dynamic type="checkbox"
id="AdviseThresholdNo"/> No</Line>
<Line>Have you conducted an IME at this time? <Dynamic
type="checkbox" id="ConductedIMEYes"/> Yes <Dynamic
type="checkbox" id="ConductedIMENo"/> No</Line>
<Line>If not, do you contemplate scheduling one? <Dynamic
type="checkbox" id="ContemplateSchedulingYes"/> Yes <Dynamic
type="checkbox" id="ContemplateSchedulingNo"/> No</Line>
<Line>Nature of injury <Dynamic type="text" id="NatureOfInjury"/></Line>
<Line>We thank you for your cooperation and are enclosing a return envelope
for your convenience.</Line>
<Line/>
<Line>Sincerely,</Line>
<Line/>
<Line/>
<Line/>
<Line/>
<Line><Dynamic type="text" id="AdjusterName"/></Line>
<Line><Dynamic type="text" id="AdjusterPhone"/></Line>
<Line/>
<Line>Claims Department</Line>
<Line/>
<Line/>
<Line>WB-204 (12-99)</Line>
</Content>
<RequiredData>
<Data fieldtype="NowDate" name="DateField"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress1"
fieldname="CustomAddress1" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress2"
fieldname="CustomAddress2" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress3"
fieldname="CustomAddress3" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress4"
fieldname="CustomAddress4" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="YourFile" fieldname="YourFile"
size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="YourInsured"
fieldname="YourInsured" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="OurFile" fieldname="OurFile"
size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="OurInsured"
fieldname="OurInsured" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="DateOfLoss"
fieldname="DateOfLoss" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="MedicalPaid"
fieldname="MedicalPaid" size="30" maxlength="20" entrytype="Numeric"/>
<Data type="Entry" fieldtype="Text" name="WageLossPaid"
fieldname="WageLossPaid" size="30" maxlength="20" entrytype="Numeric"/>
<Data type="Entry" fieldtype="Text" name="EssentialServicesPaid"
fieldname="EssentialServicesPaid" size="30" maxlength="20"
entrytype="Numeric"/>
<Data type="Entry" fieldtype="Checkbox" name="AdviseThresholdYes"
fieldname="AdviseThresholdYes"/>
<Data type="Entry" fieldtype="Checkbox" name="AdviseThresholdNo"
fieldname="AdviseThresholdNo"/>
<Data type="Entry" fieldtype="Checkbox" name="ConductedIMEYes"
fieldname="ConductedIMEYes"/>
<Data type="Entry" fieldtype="Checkbox" name="ConductedIMENo"
fieldname="ConductedIMENo"/>
<Data type="Entry" fieldtype="Checkbox" name="ContemplateSchedulingYes"
fieldname="ContemplateSchedulingYes"/>
<Data type="Entry" fieldtype="Checkbox" name="ContemplateSchedulingNo"
fieldname="ContemplateSchedulingNo"/>
<Data type="Entry" fieldtype="Text" name="NatureOfInjury"
fieldname="NatureOfInjury" size="30" maxlength="30"/>
<Data type="Merge" fieldtype="Text" name="AdjusterName"
fieldname="AdjusterName" size="30" maxlength="30"/>
<Data type="Merge" fieldtype="Text" name="AdjusterPhone"
fieldname="AdjusterPhone" size="30" maxlength="30"/>
</RequiredData>
</Form>

Any help would be greatly appreciated.
 
G

Guest

I am not following you. Would you be willing to clarify "repeater perhaps?"
How about an example?
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Curt_C said:
Repeater perhaps.


--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



Joe said:
Curt,

Since I will have no idea how many controls I am adding for a given page
(that is determined by the xml), how would I handle the ambiguity of not
knowing how many placeholders to add?

--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Curt_C said:
if I read it right you are simply adding the controls to the page, but not
specifying where.
You may want to look at the placeholder to use to add your controls to.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



:

Hello All:

I am trying to dynamically populate a web page with literal content and
controls (textboxes and checkboxes (and eventually two buttons - the buttons
do not appear in the code yet). I read an xml file and, using the values
retrieved from it, determine what text should be displayed and which controls
should be rendered and - most importantly - where those controls should be
rendered.

The ultimate goal is to have some text followed by a control that will
capture the users response and post it back to the server. For example the
page might show:

Please enter the dollar amount: [textbox goes here].
Was this an accident? [checkbox for yes] Yes [checkbox for no] No

The problem is that all of the controls are rendered at the top of the page
and all of the text renders after the closing html tag. I don't know why
this is and I don't know enough about the Render method to speak
intelligently about it. I hope that I have explained clearly what I am
trying to do. If not please let me know.

The code is here:

Structure DynamicControl
Dim Type As String
Dim FieldType As String
Dim Name As String
Dim FieldName As String
Dim Size As String
Dim MaxLength As String
Dim EntryType As String
End Structure

Private doc As XmlDocument
Private Lines As XmlNodeList
Private ReqData As XmlNodeList

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Response.BufferOutput = True
Dim Line As XmlNode
Dim ChildNode As XmlNode
Dim DynamicEntry As XmlNode

output = New HtmlTextWriter(txtWtr)

doc = New XmlDocument
doc.Load("C:\SampleForm.xml")

Lines = doc.GetElementsByTagName("Line")
ReqData = doc.GetElementsByTagName("Data")

For Each Line In Lines
If Line.HasChildNodes Then
For Each ChildNode In Line.ChildNodes
Dim attrList As XmlAttributeCollection =
ChildNode.Attributes
If Not (attrList Is Nothing) Then
Dim DynCtl As DynamicControl =
ParseDynamicCtrlData(attrList.GetNamedItem("id").Value)

Select Case DynCtl.FieldType.ToLower
Case "checkbox"
Dim c As CheckBox = New CheckBox
c.ID = attrList.GetNamedItem("id").Value
c.Text = DynCtl.Name
Me.Controls(1).Controls.Add(c)

Case "text"
Dim t As TextBox = New TextBox
t.ID = attrList.GetNamedItem("id").Value
t.MaxLength = CType(DynCtl.MaxLength, Integer)
t.Text = DynCtl.Name
Me.Controls(1).Controls.Add(t)

End Select
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
End Sub

Private Function ParseDynamicCtrlData(ByVal id As String) As
DynamicControl
Dim DataNode As XmlNode
Dim dc As DynamicControl

For Each DataNode In ReqData
If String.Compare(DataNode.Attributes("name").Value, id) = 0 Then
dc.FieldType = DataNode.Attributes("fieldtype").Value
If dc.FieldType.ToLower = "text" Then
If String.Compare(DataNode.Attributes("type").Value,
"merge") <> 0 Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value
dc.Size = DataNode.Attributes("size").Value
dc.MaxLength = DataNode.Attributes("maxlength").Value
End If

ElseIf dc.FieldType.ToLower = "checkbox" Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value

End If
Exit For
End If
Next

Return dc
End Function

The XML is here:

<Form>
<Content>
<Line><Dynamic type="text" id="DateField"/></Line>
<Line/>
<Line><Dynamic type="text" id="CustomAddress1"/></Line>
<Line><Dynamic type="text" id="CustomAddress2"/></Line>
<Line><Dynamic type="text" id="CustomAddress3"/></Line>
<Line><Dynamic type="text" id="CustomAddress4"/></Line>
<Line/>
<Line/>
<Line>RE: Your File #: <Dynamic type="text" id="YourFile"/></Line>
<Line> Your Insured: <Dynamic type="text" id="YourInsured"/></Line>
<Line> Our File #: <Dynamic type="text" id="OurFile"/></Line>
<Line> Our Insured: <Dynamic type="text" id="OurInsured"/></Line>
<Line> Date of Loss: <Dynamic type="text" id="DateOfLoss"/></Line>
<Line/>
<Line>We are asking you to please complete the following with regard to
your No-Fault file on the above mentioned insured.</Line>
<Line/>
<Line>Medical paid: <Dynamic type="text" id="MedicalPaid"/></Line>
<Line>Wage Loss paid: <Dynamic type="text" id="WageLossPaid"/></Line>
<Line>Essential Services paid: <Dynamic type="text"
id="EssentialServicesPaid"/></Line>
<Line>Advise if threshold passed: <Dynamic
type="checkbox" id="AdviseThresholdYes"/> Yes <Dynamic type="checkbox"
id="AdviseThresholdNo"/> No</Line>
<Line>Have you conducted an IME at this time? <Dynamic
type="checkbox" id="ConductedIMEYes"/> Yes <Dynamic
type="checkbox" id="ConductedIMENo"/> No</Line>
<Line>If not, do you contemplate scheduling one? <Dynamic
type="checkbox" id="ContemplateSchedulingYes"/> Yes <Dynamic
type="checkbox" id="ContemplateSchedulingNo"/> No</Line>
<Line>Nature of injury <Dynamic type="text" id="NatureOfInjury"/></Line>
<Line>We thank you for your cooperation and are enclosing a return envelope
for your convenience.</Line>
<Line/>
<Line>Sincerely,</Line>
<Line/>
<Line/>
<Line/>
<Line/>
<Line><Dynamic type="text" id="AdjusterName"/></Line>
<Line><Dynamic type="text" id="AdjusterPhone"/></Line>
<Line/>
<Line>Claims Department</Line>
<Line/>
<Line/>
<Line>WB-204 (12-99)</Line>
</Content>
<RequiredData>
<Data fieldtype="NowDate" name="DateField"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress1"
fieldname="CustomAddress1" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress2"
fieldname="CustomAddress2" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress3"
fieldname="CustomAddress3" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress4"
fieldname="CustomAddress4" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="YourFile" fieldname="YourFile"
size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="YourInsured"
fieldname="YourInsured" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="OurFile" fieldname="OurFile"
size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="OurInsured"
fieldname="OurInsured" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="DateOfLoss"
fieldname="DateOfLoss" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="MedicalPaid"
fieldname="MedicalPaid" size="30" maxlength="20" entrytype="Numeric"/>
<Data type="Entry" fieldtype="Text" name="WageLossPaid"
fieldname="WageLossPaid" size="30" maxlength="20" entrytype="Numeric"/>
<Data type="Entry" fieldtype="Text" name="EssentialServicesPaid"
fieldname="EssentialServicesPaid" size="30" maxlength="20"
entrytype="Numeric"/>
<Data type="Entry" fieldtype="Checkbox" name="AdviseThresholdYes"
fieldname="AdviseThresholdYes"/>
<Data type="Entry" fieldtype="Checkbox" name="AdviseThresholdNo"
fieldname="AdviseThresholdNo"/>
<Data type="Entry" fieldtype="Checkbox" name="ConductedIMEYes"
fieldname="ConductedIMEYes"/>
<Data type="Entry" fieldtype="Checkbox" name="ConductedIMENo"
fieldname="ConductedIMENo"/>
<Data type="Entry" fieldtype="Checkbox" name="ContemplateSchedulingYes"
fieldname="ContemplateSchedulingYes"/>
<Data type="Entry" fieldtype="Checkbox" name="ContemplateSchedulingNo"
fieldname="ContemplateSchedulingNo"/>
<Data type="Entry" fieldtype="Text" name="NatureOfInjury"
fieldname="NatureOfInjury" size="30" maxlength="30"/>
<Data type="Merge" fieldtype="Text" name="AdjusterName"
fieldname="AdjusterName" size="30" maxlength="30"/>
<Data type="Merge" fieldtype="Text" name="AdjusterPhone"
fieldname="AdjusterPhone" size="30" maxlength="30"/>
</RequiredData>
</Form>

Any help would be greatly appreciated.
 
G

Guest

<repeater>
<placeholder for control>
<placeholder for text for question>
</repeater>

The repeater is bound to the XML list for it's iteration/count

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



Joe said:
I am not following you. Would you be willing to clarify "repeater perhaps?"
How about an example?
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Curt_C said:
Repeater perhaps.


--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



Joe said:
Curt,

Since I will have no idea how many controls I am adding for a given page
(that is determined by the xml), how would I handle the ambiguity of not
knowing how many placeholders to add?

--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


:

if I read it right you are simply adding the controls to the page, but not
specifying where.
You may want to look at the placeholder to use to add your controls to.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



:

Hello All:

I am trying to dynamically populate a web page with literal content and
controls (textboxes and checkboxes (and eventually two buttons - the buttons
do not appear in the code yet). I read an xml file and, using the values
retrieved from it, determine what text should be displayed and which controls
should be rendered and - most importantly - where those controls should be
rendered.

The ultimate goal is to have some text followed by a control that will
capture the users response and post it back to the server. For example the
page might show:

Please enter the dollar amount: [textbox goes here].
Was this an accident? [checkbox for yes] Yes [checkbox for no] No

The problem is that all of the controls are rendered at the top of the page
and all of the text renders after the closing html tag. I don't know why
this is and I don't know enough about the Render method to speak
intelligently about it. I hope that I have explained clearly what I am
trying to do. If not please let me know.

The code is here:

Structure DynamicControl
Dim Type As String
Dim FieldType As String
Dim Name As String
Dim FieldName As String
Dim Size As String
Dim MaxLength As String
Dim EntryType As String
End Structure

Private doc As XmlDocument
Private Lines As XmlNodeList
Private ReqData As XmlNodeList

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Response.BufferOutput = True
Dim Line As XmlNode
Dim ChildNode As XmlNode
Dim DynamicEntry As XmlNode

output = New HtmlTextWriter(txtWtr)

doc = New XmlDocument
doc.Load("C:\SampleForm.xml")

Lines = doc.GetElementsByTagName("Line")
ReqData = doc.GetElementsByTagName("Data")

For Each Line In Lines
If Line.HasChildNodes Then
For Each ChildNode In Line.ChildNodes
Dim attrList As XmlAttributeCollection =
ChildNode.Attributes
If Not (attrList Is Nothing) Then
Dim DynCtl As DynamicControl =
ParseDynamicCtrlData(attrList.GetNamedItem("id").Value)

Select Case DynCtl.FieldType.ToLower
Case "checkbox"
Dim c As CheckBox = New CheckBox
c.ID = attrList.GetNamedItem("id").Value
c.Text = DynCtl.Name
Me.Controls(1).Controls.Add(c)

Case "text"
Dim t As TextBox = New TextBox
t.ID = attrList.GetNamedItem("id").Value
t.MaxLength = CType(DynCtl.MaxLength, Integer)
t.Text = DynCtl.Name
Me.Controls(1).Controls.Add(t)

End Select
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
End Sub

Private Function ParseDynamicCtrlData(ByVal id As String) As
DynamicControl
Dim DataNode As XmlNode
Dim dc As DynamicControl

For Each DataNode In ReqData
If String.Compare(DataNode.Attributes("name").Value, id) = 0 Then
dc.FieldType = DataNode.Attributes("fieldtype").Value
If dc.FieldType.ToLower = "text" Then
If String.Compare(DataNode.Attributes("type").Value,
"merge") <> 0 Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value
dc.Size = DataNode.Attributes("size").Value
dc.MaxLength = DataNode.Attributes("maxlength").Value
End If

ElseIf dc.FieldType.ToLower = "checkbox" Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value

End If
Exit For
End If
Next

Return dc
End Function

The XML is here:

<Form>
<Content>
<Line><Dynamic type="text" id="DateField"/></Line>
<Line/>
<Line><Dynamic type="text" id="CustomAddress1"/></Line>
<Line><Dynamic type="text" id="CustomAddress2"/></Line>
<Line><Dynamic type="text" id="CustomAddress3"/></Line>
<Line><Dynamic type="text" id="CustomAddress4"/></Line>
<Line/>
<Line/>
<Line>RE: Your File #: <Dynamic type="text" id="YourFile"/></Line>
<Line> Your Insured: <Dynamic type="text" id="YourInsured"/></Line>
<Line> Our File #: <Dynamic type="text" id="OurFile"/></Line>
<Line> Our Insured: <Dynamic type="text" id="OurInsured"/></Line>
<Line> Date of Loss: <Dynamic type="text" id="DateOfLoss"/></Line>
<Line/>
<Line>We are asking you to please complete the following with regard to
your No-Fault file on the above mentioned insured.</Line>
<Line/>
<Line>Medical paid: <Dynamic type="text" id="MedicalPaid"/></Line>
<Line>Wage Loss paid: <Dynamic type="text" id="WageLossPaid"/></Line>
<Line>Essential Services paid: <Dynamic type="text"
id="EssentialServicesPaid"/></Line>
<Line>Advise if threshold passed: <Dynamic
type="checkbox" id="AdviseThresholdYes"/> Yes <Dynamic type="checkbox"
id="AdviseThresholdNo"/> No</Line>
<Line>Have you conducted an IME at this time? <Dynamic
type="checkbox" id="ConductedIMEYes"/> Yes <Dynamic
type="checkbox" id="ConductedIMENo"/> No</Line>
<Line>If not, do you contemplate scheduling one? <Dynamic
type="checkbox" id="ContemplateSchedulingYes"/> Yes <Dynamic
type="checkbox" id="ContemplateSchedulingNo"/> No</Line>
<Line>Nature of injury <Dynamic type="text" id="NatureOfInjury"/></Line>
<Line>We thank you for your cooperation and are enclosing a return envelope
for your convenience.</Line>
<Line/>
<Line>Sincerely,</Line>
<Line/>
<Line/>
<Line/>
<Line/>
<Line><Dynamic type="text" id="AdjusterName"/></Line>
<Line><Dynamic type="text" id="AdjusterPhone"/></Line>
<Line/>
<Line>Claims Department</Line>
<Line/>
<Line/>
<Line>WB-204 (12-99)</Line>
</Content>
<RequiredData>
<Data fieldtype="NowDate" name="DateField"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress1"
fieldname="CustomAddress1" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress2"
fieldname="CustomAddress2" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress3"
fieldname="CustomAddress3" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress4"
fieldname="CustomAddress4" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="YourFile" fieldname="YourFile"
size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="YourInsured"
fieldname="YourInsured" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="OurFile" fieldname="OurFile"
size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="OurInsured"
fieldname="OurInsured" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="DateOfLoss"
fieldname="DateOfLoss" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="MedicalPaid"
fieldname="MedicalPaid" size="30" maxlength="20" entrytype="Numeric"/>
<Data type="Entry" fieldtype="Text" name="WageLossPaid"
fieldname="WageLossPaid" size="30" maxlength="20" entrytype="Numeric"/>
<Data type="Entry" fieldtype="Text" name="EssentialServicesPaid"
fieldname="EssentialServicesPaid" size="30" maxlength="20"
entrytype="Numeric"/>
<Data type="Entry" fieldtype="Checkbox" name="AdviseThresholdYes"
fieldname="AdviseThresholdYes"/>
<Data type="Entry" fieldtype="Checkbox" name="AdviseThresholdNo"
fieldname="AdviseThresholdNo"/>
<Data type="Entry" fieldtype="Checkbox" name="ConductedIMEYes"
fieldname="ConductedIMEYes"/>
<Data type="Entry" fieldtype="Checkbox" name="ConductedIMENo"
fieldname="ConductedIMENo"/>
<Data type="Entry" fieldtype="Checkbox" name="ContemplateSchedulingYes"
fieldname="ContemplateSchedulingYes"/>
<Data type="Entry" fieldtype="Checkbox" name="ContemplateSchedulingNo"
fieldname="ContemplateSchedulingNo"/>
<Data type="Entry" fieldtype="Text" name="NatureOfInjury"
fieldname="NatureOfInjury" size="30" maxlength="30"/>
<Data type="Merge" fieldtype="Text" name="AdjusterName"
fieldname="AdjusterName" size="30" maxlength="30"/>
<Data type="Merge" fieldtype="Text" name="AdjusterPhone"
fieldname="AdjusterPhone" size="30" maxlength="30"/>
</RequiredData>
</Form>

Any help would be greatly appreciated.
 
G

Guest

Sorry Curt. I really need you to spell this one out....

How would you implment this? In code? In the markup? Both?

The key here is explicitly spelling out each part of the solution that you
are recommending.

Thanks,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Curt_C said:
<repeater>
<placeholder for control>
<placeholder for text for question>
</repeater>

The repeater is bound to the XML list for it's iteration/count

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



Joe said:
I am not following you. Would you be willing to clarify "repeater perhaps?"
How about an example?
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Curt_C said:
Repeater perhaps.


--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



:

Curt,

Since I will have no idea how many controls I am adding for a given page
(that is determined by the xml), how would I handle the ambiguity of not
knowing how many placeholders to add?

--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


:

if I read it right you are simply adding the controls to the page, but not
specifying where.
You may want to look at the placeholder to use to add your controls to.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



:

Hello All:

I am trying to dynamically populate a web page with literal content and
controls (textboxes and checkboxes (and eventually two buttons - the buttons
do not appear in the code yet). I read an xml file and, using the values
retrieved from it, determine what text should be displayed and which controls
should be rendered and - most importantly - where those controls should be
rendered.

The ultimate goal is to have some text followed by a control that will
capture the users response and post it back to the server. For example the
page might show:

Please enter the dollar amount: [textbox goes here].
Was this an accident? [checkbox for yes] Yes [checkbox for no] No

The problem is that all of the controls are rendered at the top of the page
and all of the text renders after the closing html tag. I don't know why
this is and I don't know enough about the Render method to speak
intelligently about it. I hope that I have explained clearly what I am
trying to do. If not please let me know.

The code is here:

Structure DynamicControl
Dim Type As String
Dim FieldType As String
Dim Name As String
Dim FieldName As String
Dim Size As String
Dim MaxLength As String
Dim EntryType As String
End Structure

Private doc As XmlDocument
Private Lines As XmlNodeList
Private ReqData As XmlNodeList

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Response.BufferOutput = True
Dim Line As XmlNode
Dim ChildNode As XmlNode
Dim DynamicEntry As XmlNode

output = New HtmlTextWriter(txtWtr)

doc = New XmlDocument
doc.Load("C:\SampleForm.xml")

Lines = doc.GetElementsByTagName("Line")
ReqData = doc.GetElementsByTagName("Data")

For Each Line In Lines
If Line.HasChildNodes Then
For Each ChildNode In Line.ChildNodes
Dim attrList As XmlAttributeCollection =
ChildNode.Attributes
If Not (attrList Is Nothing) Then
Dim DynCtl As DynamicControl =
ParseDynamicCtrlData(attrList.GetNamedItem("id").Value)

Select Case DynCtl.FieldType.ToLower
Case "checkbox"
Dim c As CheckBox = New CheckBox
c.ID = attrList.GetNamedItem("id").Value
c.Text = DynCtl.Name
Me.Controls(1).Controls.Add(c)

Case "text"
Dim t As TextBox = New TextBox
t.ID = attrList.GetNamedItem("id").Value
t.MaxLength = CType(DynCtl.MaxLength, Integer)
t.Text = DynCtl.Name
Me.Controls(1).Controls.Add(t)

End Select
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
End Sub

Private Function ParseDynamicCtrlData(ByVal id As String) As
DynamicControl
Dim DataNode As XmlNode
Dim dc As DynamicControl

For Each DataNode In ReqData
If String.Compare(DataNode.Attributes("name").Value, id) = 0 Then
dc.FieldType = DataNode.Attributes("fieldtype").Value
If dc.FieldType.ToLower = "text" Then
If String.Compare(DataNode.Attributes("type").Value,
"merge") <> 0 Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value
dc.Size = DataNode.Attributes("size").Value
dc.MaxLength = DataNode.Attributes("maxlength").Value
End If

ElseIf dc.FieldType.ToLower = "checkbox" Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value

End If
Exit For
End If
Next

Return dc
End Function

The XML is here:

<Form>
<Content>
<Line><Dynamic type="text" id="DateField"/></Line>
<Line/>
<Line><Dynamic type="text" id="CustomAddress1"/></Line>
<Line><Dynamic type="text" id="CustomAddress2"/></Line>
<Line><Dynamic type="text" id="CustomAddress3"/></Line>
<Line><Dynamic type="text" id="CustomAddress4"/></Line>
<Line/>
<Line/>
<Line>RE: Your File #: <Dynamic type="text" id="YourFile"/></Line>
<Line> Your Insured: <Dynamic type="text" id="YourInsured"/></Line>
<Line> Our File #: <Dynamic type="text" id="OurFile"/></Line>
<Line> Our Insured: <Dynamic type="text" id="OurInsured"/></Line>
<Line> Date of Loss: <Dynamic type="text" id="DateOfLoss"/></Line>
<Line/>
<Line>We are asking you to please complete the following with regard to
your No-Fault file on the above mentioned insured.</Line>
<Line/>
<Line>Medical paid: <Dynamic type="text" id="MedicalPaid"/></Line>
<Line>Wage Loss paid: <Dynamic type="text" id="WageLossPaid"/></Line>
<Line>Essential Services paid: <Dynamic type="text"
id="EssentialServicesPaid"/></Line>
<Line>Advise if threshold passed: <Dynamic
type="checkbox" id="AdviseThresholdYes"/> Yes <Dynamic type="checkbox"
id="AdviseThresholdNo"/> No</Line>
<Line>Have you conducted an IME at this time? <Dynamic
type="checkbox" id="ConductedIMEYes"/> Yes <Dynamic
type="checkbox" id="ConductedIMENo"/> No</Line>
<Line>If not, do you contemplate scheduling one? <Dynamic
type="checkbox" id="ContemplateSchedulingYes"/> Yes <Dynamic
type="checkbox" id="ContemplateSchedulingNo"/> No</Line>
<Line>Nature of injury <Dynamic type="text" id="NatureOfInjury"/></Line>
<Line>We thank you for your cooperation and are enclosing a return envelope
for your convenience.</Line>
<Line/>
<Line>Sincerely,</Line>
<Line/>
<Line/>
<Line/>
<Line/>
<Line><Dynamic type="text" id="AdjusterName"/></Line>
<Line><Dynamic type="text" id="AdjusterPhone"/></Line>
<Line/>
<Line>Claims Department</Line>
<Line/>
<Line/>
<Line>WB-204 (12-99)</Line>
</Content>
<RequiredData>
<Data fieldtype="NowDate" name="DateField"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress1"
fieldname="CustomAddress1" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress2"
fieldname="CustomAddress2" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress3"
fieldname="CustomAddress3" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress4"
fieldname="CustomAddress4" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="YourFile" fieldname="YourFile"
size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="YourInsured"
fieldname="YourInsured" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="OurFile" fieldname="OurFile"
size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="OurInsured"
fieldname="OurInsured" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="DateOfLoss"
fieldname="DateOfLoss" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="MedicalPaid"
fieldname="MedicalPaid" size="30" maxlength="20" entrytype="Numeric"/>
<Data type="Entry" fieldtype="Text" name="WageLossPaid"
fieldname="WageLossPaid" size="30" maxlength="20" entrytype="Numeric"/>
<Data type="Entry" fieldtype="Text" name="EssentialServicesPaid"
fieldname="EssentialServicesPaid" size="30" maxlength="20"
entrytype="Numeric"/>
<Data type="Entry" fieldtype="Checkbox" name="AdviseThresholdYes"
fieldname="AdviseThresholdYes"/>
<Data type="Entry" fieldtype="Checkbox" name="AdviseThresholdNo"
fieldname="AdviseThresholdNo"/>
<Data type="Entry" fieldtype="Checkbox" name="ConductedIMEYes"
fieldname="ConductedIMEYes"/>
<Data type="Entry" fieldtype="Checkbox" name="ConductedIMENo"
fieldname="ConductedIMENo"/>
<Data type="Entry" fieldtype="Checkbox" name="ContemplateSchedulingYes"
fieldname="ContemplateSchedulingYes"/>
<Data type="Entry" fieldtype="Checkbox" name="ContemplateSchedulingNo"
fieldname="ContemplateSchedulingNo"/>
<Data type="Entry" fieldtype="Text" name="NatureOfInjury"
fieldname="NatureOfInjury" size="30" maxlength="30"/>
<Data type="Merge" fieldtype="Text" name="AdjusterName"
fieldname="AdjusterName" size="30" maxlength="30"/>
<Data type="Merge" fieldtype="Text" name="AdjusterPhone"
fieldname="AdjusterPhone" size="30" maxlength="30"/>
</RequiredData>
</Form>

Any help would be greatly appreciated.
 
G

Guest

1) Read your XML in, DataSet might be easiest.
2) Bind your repeater to it
3) in the data bound event write your control to the place holder

There are plenty of samples out there of the Repeater, if that's where you
are saying you are stuck...
I'm trying to not write it for you and instead have you try and post the
specific issues/problems that you encounter.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



Joe said:
Sorry Curt. I really need you to spell this one out....

How would you implment this? In code? In the markup? Both?

The key here is explicitly spelling out each part of the solution that you
are recommending.

Thanks,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Curt_C said:
<repeater>
<placeholder for control>
<placeholder for text for question>
</repeater>

The repeater is bound to the XML list for it's iteration/count

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



Joe said:
I am not following you. Would you be willing to clarify "repeater perhaps?"
How about an example?
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


:

Repeater perhaps.


--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



:

Curt,

Since I will have no idea how many controls I am adding for a given page
(that is determined by the xml), how would I handle the ambiguity of not
knowing how many placeholders to add?

--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


:

if I read it right you are simply adding the controls to the page, but not
specifying where.
You may want to look at the placeholder to use to add your controls to.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



:

Hello All:

I am trying to dynamically populate a web page with literal content and
controls (textboxes and checkboxes (and eventually two buttons - the buttons
do not appear in the code yet). I read an xml file and, using the values
retrieved from it, determine what text should be displayed and which controls
should be rendered and - most importantly - where those controls should be
rendered.

The ultimate goal is to have some text followed by a control that will
capture the users response and post it back to the server. For example the
page might show:

Please enter the dollar amount: [textbox goes here].
Was this an accident? [checkbox for yes] Yes [checkbox for no] No

The problem is that all of the controls are rendered at the top of the page
and all of the text renders after the closing html tag. I don't know why
this is and I don't know enough about the Render method to speak
intelligently about it. I hope that I have explained clearly what I am
trying to do. If not please let me know.

The code is here:

Structure DynamicControl
Dim Type As String
Dim FieldType As String
Dim Name As String
Dim FieldName As String
Dim Size As String
Dim MaxLength As String
Dim EntryType As String
End Structure

Private doc As XmlDocument
Private Lines As XmlNodeList
Private ReqData As XmlNodeList

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Response.BufferOutput = True
Dim Line As XmlNode
Dim ChildNode As XmlNode
Dim DynamicEntry As XmlNode

output = New HtmlTextWriter(txtWtr)

doc = New XmlDocument
doc.Load("C:\SampleForm.xml")

Lines = doc.GetElementsByTagName("Line")
ReqData = doc.GetElementsByTagName("Data")

For Each Line In Lines
If Line.HasChildNodes Then
For Each ChildNode In Line.ChildNodes
Dim attrList As XmlAttributeCollection =
ChildNode.Attributes
If Not (attrList Is Nothing) Then
Dim DynCtl As DynamicControl =
ParseDynamicCtrlData(attrList.GetNamedItem("id").Value)

Select Case DynCtl.FieldType.ToLower
Case "checkbox"
Dim c As CheckBox = New CheckBox
c.ID = attrList.GetNamedItem("id").Value
c.Text = DynCtl.Name
Me.Controls(1).Controls.Add(c)

Case "text"
Dim t As TextBox = New TextBox
t.ID = attrList.GetNamedItem("id").Value
t.MaxLength = CType(DynCtl.MaxLength, Integer)
t.Text = DynCtl.Name
Me.Controls(1).Controls.Add(t)

End Select
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
End Sub

Private Function ParseDynamicCtrlData(ByVal id As String) As
DynamicControl
Dim DataNode As XmlNode
Dim dc As DynamicControl

For Each DataNode In ReqData
If String.Compare(DataNode.Attributes("name").Value, id) = 0 Then
dc.FieldType = DataNode.Attributes("fieldtype").Value
If dc.FieldType.ToLower = "text" Then
If String.Compare(DataNode.Attributes("type").Value,
"merge") <> 0 Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value
dc.Size = DataNode.Attributes("size").Value
dc.MaxLength = DataNode.Attributes("maxlength").Value
End If

ElseIf dc.FieldType.ToLower = "checkbox" Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value

End If
Exit For
End If
Next

Return dc
End Function

The XML is here:

<Form>
<Content>
<Line><Dynamic type="text" id="DateField"/></Line>
<Line/>
<Line><Dynamic type="text" id="CustomAddress1"/></Line>
<Line><Dynamic type="text" id="CustomAddress2"/></Line>
<Line><Dynamic type="text" id="CustomAddress3"/></Line>
<Line><Dynamic type="text" id="CustomAddress4"/></Line>
<Line/>
<Line/>
<Line>RE: Your File #: <Dynamic type="text" id="YourFile"/></Line>
<Line> Your Insured: <Dynamic type="text" id="YourInsured"/></Line>
<Line> Our File #: <Dynamic type="text" id="OurFile"/></Line>
<Line> Our Insured: <Dynamic type="text" id="OurInsured"/></Line>
<Line> Date of Loss: <Dynamic type="text" id="DateOfLoss"/></Line>
<Line/>
<Line>We are asking you to please complete the following with regard to
your No-Fault file on the above mentioned insured.</Line>
<Line/>
<Line>Medical paid: <Dynamic type="text" id="MedicalPaid"/></Line>
<Line>Wage Loss paid: <Dynamic type="text" id="WageLossPaid"/></Line>
<Line>Essential Services paid: <Dynamic type="text"
id="EssentialServicesPaid"/></Line>
<Line>Advise if threshold passed: <Dynamic
type="checkbox" id="AdviseThresholdYes"/> Yes <Dynamic type="checkbox"
id="AdviseThresholdNo"/> No</Line>
<Line>Have you conducted an IME at this time? <Dynamic
type="checkbox" id="ConductedIMEYes"/> Yes <Dynamic
type="checkbox" id="ConductedIMENo"/> No</Line>
<Line>If not, do you contemplate scheduling one? <Dynamic
type="checkbox" id="ContemplateSchedulingYes"/> Yes <Dynamic
type="checkbox" id="ContemplateSchedulingNo"/> No</Line>
<Line>Nature of injury <Dynamic type="text" id="NatureOfInjury"/></Line>
<Line>We thank you for your cooperation and are enclosing a return envelope
for your convenience.</Line>
<Line/>
<Line>Sincerely,</Line>
<Line/>
<Line/>
<Line/>
<Line/>
<Line><Dynamic type="text" id="AdjusterName"/></Line>
<Line><Dynamic type="text" id="AdjusterPhone"/></Line>
<Line/>
<Line>Claims Department</Line>
<Line/>
<Line/>
<Line>WB-204 (12-99)</Line>
</Content>
<RequiredData>
<Data fieldtype="NowDate" name="DateField"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress1"
fieldname="CustomAddress1" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress2"
fieldname="CustomAddress2" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress3"
fieldname="CustomAddress3" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress4"
fieldname="CustomAddress4" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="YourFile" fieldname="YourFile"
size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="YourInsured"
fieldname="YourInsured" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="OurFile" fieldname="OurFile"
size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="OurInsured"
fieldname="OurInsured" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="DateOfLoss"
fieldname="DateOfLoss" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="MedicalPaid"
fieldname="MedicalPaid" size="30" maxlength="20" entrytype="Numeric"/>
<Data type="Entry" fieldtype="Text" name="WageLossPaid"
fieldname="WageLossPaid" size="30" maxlength="20" entrytype="Numeric"/>
<Data type="Entry" fieldtype="Text" name="EssentialServicesPaid"
fieldname="EssentialServicesPaid" size="30" maxlength="20"
entrytype="Numeric"/>
<Data type="Entry" fieldtype="Checkbox" name="AdviseThresholdYes"
fieldname="AdviseThresholdYes"/>
<Data type="Entry" fieldtype="Checkbox" name="AdviseThresholdNo"
fieldname="AdviseThresholdNo"/>
<Data type="Entry" fieldtype="Checkbox" name="ConductedIMEYes"
fieldname="ConductedIMEYes"/>
<Data type="Entry" fieldtype="Checkbox" name="ConductedIMENo"
fieldname="ConductedIMENo"/>
<Data type="Entry" fieldtype="Checkbox" name="ContemplateSchedulingYes"
fieldname="ContemplateSchedulingYes"/>
<Data type="Entry" fieldtype="Checkbox" name="ContemplateSchedulingNo"
fieldname="ContemplateSchedulingNo"/>
<Data type="Entry" fieldtype="Text" name="NatureOfInjury"
fieldname="NatureOfInjury" size="30" maxlength="30"/>
<Data type="Merge" fieldtype="Text" name="AdjusterName"
fieldname="AdjusterName" size="30" maxlength="30"/>
<Data type="Merge" fieldtype="Text" name="AdjusterPhone"
fieldname="AdjusterPhone" size="30" maxlength="30"/>
</RequiredData>
</Form>
 
G

Guest

Curt,

The issue is that I have never used a placeholder before. I have no
experience with them. That's why I am asking for an example.
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Curt_C said:
1) Read your XML in, DataSet might be easiest.
2) Bind your repeater to it
3) in the data bound event write your control to the place holder

There are plenty of samples out there of the Repeater, if that's where you
are saying you are stuck...
I'm trying to not write it for you and instead have you try and post the
specific issues/problems that you encounter.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



Joe said:
Sorry Curt. I really need you to spell this one out....

How would you implment this? In code? In the markup? Both?

The key here is explicitly spelling out each part of the solution that you
are recommending.

Thanks,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Curt_C said:
<repeater>
<placeholder for control>
<placeholder for text for question>
</repeater>

The repeater is bound to the XML list for it's iteration/count

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



:

I am not following you. Would you be willing to clarify "repeater perhaps?"
How about an example?
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


:

Repeater perhaps.


--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



:

Curt,

Since I will have no idea how many controls I am adding for a given page
(that is determined by the xml), how would I handle the ambiguity of not
knowing how many placeholders to add?

--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


:

if I read it right you are simply adding the controls to the page, but not
specifying where.
You may want to look at the placeholder to use to add your controls to.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



:

Hello All:

I am trying to dynamically populate a web page with literal content and
controls (textboxes and checkboxes (and eventually two buttons - the buttons
do not appear in the code yet). I read an xml file and, using the values
retrieved from it, determine what text should be displayed and which controls
should be rendered and - most importantly - where those controls should be
rendered.

The ultimate goal is to have some text followed by a control that will
capture the users response and post it back to the server. For example the
page might show:

Please enter the dollar amount: [textbox goes here].
Was this an accident? [checkbox for yes] Yes [checkbox for no] No

The problem is that all of the controls are rendered at the top of the page
and all of the text renders after the closing html tag. I don't know why
this is and I don't know enough about the Render method to speak
intelligently about it. I hope that I have explained clearly what I am
trying to do. If not please let me know.

The code is here:

Structure DynamicControl
Dim Type As String
Dim FieldType As String
Dim Name As String
Dim FieldName As String
Dim Size As String
Dim MaxLength As String
Dim EntryType As String
End Structure

Private doc As XmlDocument
Private Lines As XmlNodeList
Private ReqData As XmlNodeList

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Response.BufferOutput = True
Dim Line As XmlNode
Dim ChildNode As XmlNode
Dim DynamicEntry As XmlNode

output = New HtmlTextWriter(txtWtr)

doc = New XmlDocument
doc.Load("C:\SampleForm.xml")

Lines = doc.GetElementsByTagName("Line")
ReqData = doc.GetElementsByTagName("Data")

For Each Line In Lines
If Line.HasChildNodes Then
For Each ChildNode In Line.ChildNodes
Dim attrList As XmlAttributeCollection =
ChildNode.Attributes
If Not (attrList Is Nothing) Then
Dim DynCtl As DynamicControl =
ParseDynamicCtrlData(attrList.GetNamedItem("id").Value)

Select Case DynCtl.FieldType.ToLower
Case "checkbox"
Dim c As CheckBox = New CheckBox
c.ID = attrList.GetNamedItem("id").Value
c.Text = DynCtl.Name
Me.Controls(1).Controls.Add(c)

Case "text"
Dim t As TextBox = New TextBox
t.ID = attrList.GetNamedItem("id").Value
t.MaxLength = CType(DynCtl.MaxLength, Integer)
t.Text = DynCtl.Name
Me.Controls(1).Controls.Add(t)

End Select
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
End Sub

Private Function ParseDynamicCtrlData(ByVal id As String) As
DynamicControl
Dim DataNode As XmlNode
Dim dc As DynamicControl

For Each DataNode In ReqData
If String.Compare(DataNode.Attributes("name").Value, id) = 0 Then
dc.FieldType = DataNode.Attributes("fieldtype").Value
If dc.FieldType.ToLower = "text" Then
If String.Compare(DataNode.Attributes("type").Value,
"merge") <> 0 Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value
dc.Size = DataNode.Attributes("size").Value
dc.MaxLength = DataNode.Attributes("maxlength").Value
End If

ElseIf dc.FieldType.ToLower = "checkbox" Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value

End If
Exit For
End If
Next

Return dc
End Function

The XML is here:

<Form>
<Content>
<Line><Dynamic type="text" id="DateField"/></Line>
<Line/>
<Line><Dynamic type="text" id="CustomAddress1"/></Line>
<Line><Dynamic type="text" id="CustomAddress2"/></Line>
<Line><Dynamic type="text" id="CustomAddress3"/></Line>
<Line><Dynamic type="text" id="CustomAddress4"/></Line>
<Line/>
<Line/>
<Line>RE: Your File #: <Dynamic type="text" id="YourFile"/></Line>
<Line> Your Insured: <Dynamic type="text" id="YourInsured"/></Line>
<Line> Our File #: <Dynamic type="text" id="OurFile"/></Line>
<Line> Our Insured: <Dynamic type="text" id="OurInsured"/></Line>
<Line> Date of Loss: <Dynamic type="text" id="DateOfLoss"/></Line>
<Line/>
<Line>We are asking you to please complete the following with regard to
your No-Fault file on the above mentioned insured.</Line>
<Line/>
<Line>Medical paid: <Dynamic type="text" id="MedicalPaid"/></Line>
<Line>Wage Loss paid: <Dynamic type="text" id="WageLossPaid"/></Line>
<Line>Essential Services paid: <Dynamic type="text"
id="EssentialServicesPaid"/></Line>
<Line>Advise if threshold passed: <Dynamic
type="checkbox" id="AdviseThresholdYes"/> Yes <Dynamic type="checkbox"
id="AdviseThresholdNo"/> No</Line>
<Line>Have you conducted an IME at this time? <Dynamic
type="checkbox" id="ConductedIMEYes"/> Yes <Dynamic
type="checkbox" id="ConductedIMENo"/> No</Line>
<Line>If not, do you contemplate scheduling one? <Dynamic
type="checkbox" id="ContemplateSchedulingYes"/> Yes <Dynamic
type="checkbox" id="ContemplateSchedulingNo"/> No</Line>
<Line>Nature of injury <Dynamic type="text" id="NatureOfInjury"/></Line>
<Line>We thank you for your cooperation and are enclosing a return envelope
for your convenience.</Line>
<Line/>
<Line>Sincerely,</Line>
<Line/>
<Line/>
<Line/>
<Line/>
<Line><Dynamic type="text" id="AdjusterName"/></Line>
<Line><Dynamic type="text" id="AdjusterPhone"/></Line>
<Line/>
<Line>Claims Department</Line>
<Line/>
<Line/>
<Line>WB-204 (12-99)</Line>
</Content>
<RequiredData>
<Data fieldtype="NowDate" name="DateField"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress1"
fieldname="CustomAddress1" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress2"
fieldname="CustomAddress2" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress3"
fieldname="CustomAddress3" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress4"
fieldname="CustomAddress4" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="YourFile" fieldname="YourFile"
size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="YourInsured"
fieldname="YourInsured" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="OurFile" fieldname="OurFile"
size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="OurInsured"
fieldname="OurInsured" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="DateOfLoss"
fieldname="DateOfLoss" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="MedicalPaid"
fieldname="MedicalPaid" size="30" maxlength="20" entrytype="Numeric"/>
<Data type="Entry" fieldtype="Text" name="WageLossPaid"
fieldname="WageLossPaid" size="30" maxlength="20" entrytype="Numeric"/>
<Data type="Entry" fieldtype="Text" name="EssentialServicesPaid"
fieldname="EssentialServicesPaid" size="30" maxlength="20"
entrytype="Numeric"/>
<Data type="Entry" fieldtype="Checkbox" name="AdviseThresholdYes"
fieldname="AdviseThresholdYes"/>
 
G

Guest

http://aspnet.4guysfromrolla.com/articles/081402-1.aspx
http://www.devx.com/codemag/Article/20144/0/page/2

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



Joe said:
Curt,

The issue is that I have never used a placeholder before. I have no
experience with them. That's why I am asking for an example.
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Curt_C said:
1) Read your XML in, DataSet might be easiest.
2) Bind your repeater to it
3) in the data bound event write your control to the place holder

There are plenty of samples out there of the Repeater, if that's where you
are saying you are stuck...
I'm trying to not write it for you and instead have you try and post the
specific issues/problems that you encounter.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



Joe said:
Sorry Curt. I really need you to spell this one out....

How would you implment this? In code? In the markup? Both?

The key here is explicitly spelling out each part of the solution that you
are recommending.

Thanks,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


:

<repeater>
<placeholder for control>
<placeholder for text for question>
</repeater>

The repeater is bound to the XML list for it's iteration/count

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



:

I am not following you. Would you be willing to clarify "repeater perhaps?"
How about an example?
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


:

Repeater perhaps.


--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



:

Curt,

Since I will have no idea how many controls I am adding for a given page
(that is determined by the xml), how would I handle the ambiguity of not
knowing how many placeholders to add?

--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


:

if I read it right you are simply adding the controls to the page, but not
specifying where.
You may want to look at the placeholder to use to add your controls to.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



:

Hello All:

I am trying to dynamically populate a web page with literal content and
controls (textboxes and checkboxes (and eventually two buttons - the buttons
do not appear in the code yet). I read an xml file and, using the values
retrieved from it, determine what text should be displayed and which controls
should be rendered and - most importantly - where those controls should be
rendered.

The ultimate goal is to have some text followed by a control that will
capture the users response and post it back to the server. For example the
page might show:

Please enter the dollar amount: [textbox goes here].
Was this an accident? [checkbox for yes] Yes [checkbox for no] No

The problem is that all of the controls are rendered at the top of the page
and all of the text renders after the closing html tag. I don't know why
this is and I don't know enough about the Render method to speak
intelligently about it. I hope that I have explained clearly what I am
trying to do. If not please let me know.

The code is here:

Structure DynamicControl
Dim Type As String
Dim FieldType As String
Dim Name As String
Dim FieldName As String
Dim Size As String
Dim MaxLength As String
Dim EntryType As String
End Structure

Private doc As XmlDocument
Private Lines As XmlNodeList
Private ReqData As XmlNodeList

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Response.BufferOutput = True
Dim Line As XmlNode
Dim ChildNode As XmlNode
Dim DynamicEntry As XmlNode

output = New HtmlTextWriter(txtWtr)

doc = New XmlDocument
doc.Load("C:\SampleForm.xml")

Lines = doc.GetElementsByTagName("Line")
ReqData = doc.GetElementsByTagName("Data")

For Each Line In Lines
If Line.HasChildNodes Then
For Each ChildNode In Line.ChildNodes
Dim attrList As XmlAttributeCollection =
ChildNode.Attributes
If Not (attrList Is Nothing) Then
Dim DynCtl As DynamicControl =
ParseDynamicCtrlData(attrList.GetNamedItem("id").Value)

Select Case DynCtl.FieldType.ToLower
Case "checkbox"
Dim c As CheckBox = New CheckBox
c.ID = attrList.GetNamedItem("id").Value
c.Text = DynCtl.Name
Me.Controls(1).Controls.Add(c)

Case "text"
Dim t As TextBox = New TextBox
t.ID = attrList.GetNamedItem("id").Value
t.MaxLength = CType(DynCtl.MaxLength, Integer)
t.Text = DynCtl.Name
Me.Controls(1).Controls.Add(t)

End Select
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
End Sub

Private Function ParseDynamicCtrlData(ByVal id As String) As
DynamicControl
Dim DataNode As XmlNode
Dim dc As DynamicControl

For Each DataNode In ReqData
If String.Compare(DataNode.Attributes("name").Value, id) = 0 Then
dc.FieldType = DataNode.Attributes("fieldtype").Value
If dc.FieldType.ToLower = "text" Then
If String.Compare(DataNode.Attributes("type").Value,
"merge") <> 0 Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value
dc.Size = DataNode.Attributes("size").Value
dc.MaxLength = DataNode.Attributes("maxlength").Value
End If

ElseIf dc.FieldType.ToLower = "checkbox" Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value

End If
Exit For
End If
Next

Return dc
End Function

The XML is here:

<Form>
<Content>
<Line><Dynamic type="text" id="DateField"/></Line>
<Line/>
<Line><Dynamic type="text" id="CustomAddress1"/></Line>
<Line><Dynamic type="text" id="CustomAddress2"/></Line>
<Line><Dynamic type="text" id="CustomAddress3"/></Line>
<Line><Dynamic type="text" id="CustomAddress4"/></Line>
<Line/>
<Line/>
<Line>RE: Your File #: <Dynamic type="text" id="YourFile"/></Line>
<Line> Your Insured: <Dynamic type="text" id="YourInsured"/></Line>
<Line> Our File #: <Dynamic type="text" id="OurFile"/></Line>
<Line> Our Insured: <Dynamic type="text" id="OurInsured"/></Line>
<Line> Date of Loss: <Dynamic type="text" id="DateOfLoss"/></Line>
<Line/>
<Line>We are asking you to please complete the following with regard to
your No-Fault file on the above mentioned insured.</Line>
<Line/>
<Line>Medical paid: <Dynamic type="text" id="MedicalPaid"/></Line>
<Line>Wage Loss paid: <Dynamic type="text" id="WageLossPaid"/></Line>
<Line>Essential Services paid: <Dynamic type="text"
id="EssentialServicesPaid"/></Line>
<Line>Advise if threshold passed: <Dynamic
type="checkbox" id="AdviseThresholdYes"/> Yes <Dynamic type="checkbox"
id="AdviseThresholdNo"/> No</Line>
<Line>Have you conducted an IME at this time? <Dynamic
type="checkbox" id="ConductedIMEYes"/> Yes <Dynamic
type="checkbox" id="ConductedIMENo"/> No</Line>
<Line>If not, do you contemplate scheduling one? <Dynamic
type="checkbox" id="ContemplateSchedulingYes"/> Yes <Dynamic
type="checkbox" id="ContemplateSchedulingNo"/> No</Line>
<Line>Nature of injury <Dynamic type="text" id="NatureOfInjury"/></Line>
<Line>We thank you for your cooperation and are enclosing a return envelope
for your convenience.</Line>
<Line/>
<Line>Sincerely,</Line>
<Line/>
<Line/>
<Line/>
<Line/>
<Line><Dynamic type="text" id="AdjusterName"/></Line>
<Line><Dynamic type="text" id="AdjusterPhone"/></Line>
<Line/>
<Line>Claims Department</Line>
<Line/>
<Line/>
<Line>WB-204 (12-99)</Line>
</Content>
<RequiredData>
<Data fieldtype="NowDate" name="DateField"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress1"
fieldname="CustomAddress1" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress2"
fieldname="CustomAddress2" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress3"
fieldname="CustomAddress3" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress4"
fieldname="CustomAddress4" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="YourFile" fieldname="YourFile"
size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="YourInsured"
fieldname="YourInsured" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="OurFile" fieldname="OurFile"
size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="OurInsured"
 
G

Guest

Thanks Curt. I've already read these. But they don't solve the problem.
Here's why: I can't statically place "Placeholder" controls on this form. I
have no idea how many I would need or where they should go.

The controls (placehodlers or otherwise) must be dynamically added to the
form. Then they must be dynamically populated. Remember, I do not know what
content or controls will be requried for a given form. That is determined
solely by the XML.

Do you know of any articles that discuss this (dynamically adding
Placeholder controls (to be populated at some later time in the cdoe))?

Thanks,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Curt_C said:
http://aspnet.4guysfromrolla.com/articles/081402-1.aspx
http://www.devx.com/codemag/Article/20144/0/page/2

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



Joe said:
Curt,

The issue is that I have never used a placeholder before. I have no
experience with them. That's why I am asking for an example.
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Curt_C said:
1) Read your XML in, DataSet might be easiest.
2) Bind your repeater to it
3) in the data bound event write your control to the place holder

There are plenty of samples out there of the Repeater, if that's where you
are saying you are stuck...
I'm trying to not write it for you and instead have you try and post the
specific issues/problems that you encounter.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



:

Sorry Curt. I really need you to spell this one out....

How would you implment this? In code? In the markup? Both?

The key here is explicitly spelling out each part of the solution that you
are recommending.

Thanks,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


:

<repeater>
<placeholder for control>
<placeholder for text for question>
</repeater>

The repeater is bound to the XML list for it's iteration/count

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



:

I am not following you. Would you be willing to clarify "repeater perhaps?"
How about an example?
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


:

Repeater perhaps.


--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



:

Curt,

Since I will have no idea how many controls I am adding for a given page
(that is determined by the xml), how would I handle the ambiguity of not
knowing how many placeholders to add?

--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


:

if I read it right you are simply adding the controls to the page, but not
specifying where.
You may want to look at the placeholder to use to add your controls to.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



:

Hello All:

I am trying to dynamically populate a web page with literal content and
controls (textboxes and checkboxes (and eventually two buttons - the buttons
do not appear in the code yet). I read an xml file and, using the values
retrieved from it, determine what text should be displayed and which controls
should be rendered and - most importantly - where those controls should be
rendered.

The ultimate goal is to have some text followed by a control that will
capture the users response and post it back to the server. For example the
page might show:

Please enter the dollar amount: [textbox goes here].
Was this an accident? [checkbox for yes] Yes [checkbox for no] No

The problem is that all of the controls are rendered at the top of the page
and all of the text renders after the closing html tag. I don't know why
this is and I don't know enough about the Render method to speak
intelligently about it. I hope that I have explained clearly what I am
trying to do. If not please let me know.

The code is here:

Structure DynamicControl
Dim Type As String
Dim FieldType As String
Dim Name As String
Dim FieldName As String
Dim Size As String
Dim MaxLength As String
Dim EntryType As String
End Structure

Private doc As XmlDocument
Private Lines As XmlNodeList
Private ReqData As XmlNodeList

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Response.BufferOutput = True
Dim Line As XmlNode
Dim ChildNode As XmlNode
Dim DynamicEntry As XmlNode

output = New HtmlTextWriter(txtWtr)

doc = New XmlDocument
doc.Load("C:\SampleForm.xml")

Lines = doc.GetElementsByTagName("Line")
ReqData = doc.GetElementsByTagName("Data")

For Each Line In Lines
If Line.HasChildNodes Then
For Each ChildNode In Line.ChildNodes
Dim attrList As XmlAttributeCollection =
ChildNode.Attributes
If Not (attrList Is Nothing) Then
Dim DynCtl As DynamicControl =
ParseDynamicCtrlData(attrList.GetNamedItem("id").Value)

Select Case DynCtl.FieldType.ToLower
Case "checkbox"
Dim c As CheckBox = New CheckBox
c.ID = attrList.GetNamedItem("id").Value
c.Text = DynCtl.Name
Me.Controls(1).Controls.Add(c)

Case "text"
Dim t As TextBox = New TextBox
t.ID = attrList.GetNamedItem("id").Value
t.MaxLength = CType(DynCtl.MaxLength, Integer)
t.Text = DynCtl.Name
Me.Controls(1).Controls.Add(t)

End Select
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
End Sub

Private Function ParseDynamicCtrlData(ByVal id As String) As
DynamicControl
Dim DataNode As XmlNode
Dim dc As DynamicControl

For Each DataNode In ReqData
If String.Compare(DataNode.Attributes("name").Value, id) = 0 Then
dc.FieldType = DataNode.Attributes("fieldtype").Value
If dc.FieldType.ToLower = "text" Then
If String.Compare(DataNode.Attributes("type").Value,
"merge") <> 0 Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value
dc.Size = DataNode.Attributes("size").Value
dc.MaxLength = DataNode.Attributes("maxlength").Value
End If

ElseIf dc.FieldType.ToLower = "checkbox" Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value

End If
Exit For
End If
Next

Return dc
End Function

The XML is here:

<Form>
<Content>
<Line><Dynamic type="text" id="DateField"/></Line>
<Line/>
<Line><Dynamic type="text" id="CustomAddress1"/></Line>
<Line><Dynamic type="text" id="CustomAddress2"/></Line>
<Line><Dynamic type="text" id="CustomAddress3"/></Line>
<Line><Dynamic type="text" id="CustomAddress4"/></Line>
<Line/>
<Line/>
<Line>RE: Your File #: <Dynamic type="text" id="YourFile"/></Line>
<Line> Your Insured: <Dynamic type="text" id="YourInsured"/></Line>
<Line> Our File #: <Dynamic type="text" id="OurFile"/></Line>
<Line> Our Insured: <Dynamic type="text" id="OurInsured"/></Line>
<Line> Date of Loss: <Dynamic type="text" id="DateOfLoss"/></Line>
<Line/>
<Line>We are asking you to please complete the following with regard to
your No-Fault file on the above mentioned insured.</Line>
<Line/>
<Line>Medical paid: <Dynamic type="text" id="MedicalPaid"/></Line>
<Line>Wage Loss paid: <Dynamic type="text" id="WageLossPaid"/></Line>
<Line>Essential Services paid: <Dynamic type="text"
id="EssentialServicesPaid"/></Line>
<Line>Advise if threshold passed: <Dynamic
type="checkbox" id="AdviseThresholdYes"/> Yes <Dynamic type="checkbox"
id="AdviseThresholdNo"/> No</Line>
<Line>Have you conducted an IME at this time? <Dynamic
type="checkbox" id="ConductedIMEYes"/> Yes <Dynamic
type="checkbox" id="ConductedIMENo"/> No</Line>
<Line>If not, do you contemplate scheduling one? <Dynamic
type="checkbox" id="ContemplateSchedulingYes"/> Yes <Dynamic
type="checkbox" id="ContemplateSchedulingNo"/> No</Line>
<Line>Nature of injury <Dynamic type="text" id="NatureOfInjury"/></Line>
<Line>We thank you for your cooperation and are enclosing a return envelope
for your convenience.</Line>
<Line/>
<Line>Sincerely,</Line>
<Line/>
<Line/>
<Line/>
<Line/>
<Line><Dynamic type="text" id="AdjusterName"/></Line>
<Line><Dynamic type="text" id="AdjusterPhone"/></Line>
<Line/>
<Line>Claims Department</Line>
<Line/>
<Line/>
<Line>WB-204 (12-99)</Line>
</Content>
<RequiredData>
<Data fieldtype="NowDate" name="DateField"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress1"
fieldname="CustomAddress1" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress2"
 
B

Bruce Barker

that becuase you add controls to

Me.Controls(1).

making them children of the first control on the page, while you add text to

Me.Controls

adding after the last control on the page.


-- bruce (sqlwork.com)


Joe said:
Hello All:

I am trying to dynamically populate a web page with literal content and
controls (textboxes and checkboxes (and eventually two buttons - the
buttons
do not appear in the code yet). I read an xml file and, using the values
retrieved from it, determine what text should be displayed and which
controls
should be rendered and - most importantly - where those controls should be
rendered.

The ultimate goal is to have some text followed by a control that will
capture the users response and post it back to the server. For example the
page might show:

Please enter the dollar amount: [textbox goes here].
Was this an accident? [checkbox for yes] Yes [checkbox for no] No

The problem is that all of the controls are rendered at the top of the
page
and all of the text renders after the closing html tag. I don't know why
this is and I don't know enough about the Render method to speak
intelligently about it. I hope that I have explained clearly what I am
trying to do. If not please let me know.

The code is here:

Structure DynamicControl
Dim Type As String
Dim FieldType As String
Dim Name As String
Dim FieldName As String
Dim Size As String
Dim MaxLength As String
Dim EntryType As String
End Structure

Private doc As XmlDocument
Private Lines As XmlNodeList
Private ReqData As XmlNodeList

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Response.BufferOutput = True
Dim Line As XmlNode
Dim ChildNode As XmlNode
Dim DynamicEntry As XmlNode

output = New HtmlTextWriter(txtWtr)

doc = New XmlDocument
doc.Load("C:\SampleForm.xml")

Lines = doc.GetElementsByTagName("Line")
ReqData = doc.GetElementsByTagName("Data")

For Each Line In Lines
If Line.HasChildNodes Then
For Each ChildNode In Line.ChildNodes
Dim attrList As XmlAttributeCollection =
ChildNode.Attributes
If Not (attrList Is Nothing) Then
Dim DynCtl As DynamicControl =
ParseDynamicCtrlData(attrList.GetNamedItem("id").Value)

Select Case DynCtl.FieldType.ToLower
Case "checkbox"
Dim c As CheckBox = New CheckBox
c.ID = attrList.GetNamedItem("id").Value
c.Text = DynCtl.Name
Me.Controls(1).Controls.Add(c)

Case "text"
Dim t As TextBox = New TextBox
t.ID = attrList.GetNamedItem("id").Value
t.MaxLength = CType(DynCtl.MaxLength,
Integer)
t.Text = DynCtl.Name
Me.Controls(1).Controls.Add(t)

End Select
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
End Sub

Private Function ParseDynamicCtrlData(ByVal id As String) As
DynamicControl
Dim DataNode As XmlNode
Dim dc As DynamicControl

For Each DataNode In ReqData
If String.Compare(DataNode.Attributes("name").Value, id) = 0
Then
dc.FieldType = DataNode.Attributes("fieldtype").Value
If dc.FieldType.ToLower = "text" Then
If String.Compare(DataNode.Attributes("type").Value,
"merge") <> 0 Then
dc.FieldName =
DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value
dc.Size = DataNode.Attributes("size").Value
dc.MaxLength =
DataNode.Attributes("maxlength").Value
End If

ElseIf dc.FieldType.ToLower = "checkbox" Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value

End If
Exit For
End If
Next

Return dc
End Function

The XML is here:

<Form>
<Content>
<Line><Dynamic type="text" id="DateField"/></Line>
<Line/>
<Line><Dynamic type="text" id="CustomAddress1"/></Line>
<Line><Dynamic type="text" id="CustomAddress2"/></Line>
<Line><Dynamic type="text" id="CustomAddress3"/></Line>
<Line><Dynamic type="text" id="CustomAddress4"/></Line>
<Line/>
<Line/>
<Line>RE: Your File #: <Dynamic type="text" id="YourFile"/></Line>
<Line> Your Insured: <Dynamic type="text"
id="YourInsured"/></Line>
<Line> Our File #: <Dynamic type="text" id="OurFile"/></Line>
<Line> Our Insured: <Dynamic type="text" id="OurInsured"/></Line>
<Line> Date of Loss: <Dynamic type="text" id="DateOfLoss"/></Line>
<Line/>
<Line>We are asking you to please complete the following with regard to
your No-Fault file on the above mentioned insured.</Line>
<Line/>
<Line>Medical paid: <Dynamic type="text" id="MedicalPaid"/></Line>
<Line>Wage Loss paid: <Dynamic type="text" id="WageLossPaid"/></Line>
<Line>Essential Services paid: <Dynamic type="text"
id="EssentialServicesPaid"/></Line>
<Line>Advise if threshold passed: <Dynamic
type="checkbox" id="AdviseThresholdYes"/> Yes <Dynamic type="checkbox"
id="AdviseThresholdNo"/> No</Line>
<Line>Have you conducted an IME at this time? <Dynamic
type="checkbox" id="ConductedIMEYes"/> Yes <Dynamic
type="checkbox" id="ConductedIMENo"/> No</Line>
<Line>If not, do you contemplate scheduling one? <Dynamic
type="checkbox" id="ContemplateSchedulingYes"/> Yes <Dynamic
type="checkbox" id="ContemplateSchedulingNo"/> No</Line>
<Line>Nature of injury <Dynamic type="text" id="NatureOfInjury"/></Line>
<Line>We thank you for your cooperation and are enclosing a return
envelope
for your convenience.</Line>
<Line/>
<Line>Sincerely,</Line>
<Line/>
<Line/>
<Line/>
<Line/>
<Line><Dynamic type="text" id="AdjusterName"/></Line>
<Line><Dynamic type="text" id="AdjusterPhone"/></Line>
<Line/>
<Line>Claims Department</Line>
<Line/>
<Line/>
<Line>WB-204 (12-99)</Line>
</Content>
<RequiredData>
<Data fieldtype="NowDate" name="DateField"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress1"
fieldname="CustomAddress1" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress2"
fieldname="CustomAddress2" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress3"
fieldname="CustomAddress3" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress4"
fieldname="CustomAddress4" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="YourFile" fieldname="YourFile"
size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="YourInsured"
fieldname="YourInsured" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="OurFile" fieldname="OurFile"
size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="OurInsured"
fieldname="OurInsured" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="DateOfLoss"
fieldname="DateOfLoss" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="MedicalPaid"
fieldname="MedicalPaid" size="30" maxlength="20" entrytype="Numeric"/>
<Data type="Entry" fieldtype="Text" name="WageLossPaid"
fieldname="WageLossPaid" size="30" maxlength="20" entrytype="Numeric"/>
<Data type="Entry" fieldtype="Text" name="EssentialServicesPaid"
fieldname="EssentialServicesPaid" size="30" maxlength="20"
entrytype="Numeric"/>
<Data type="Entry" fieldtype="Checkbox" name="AdviseThresholdYes"
fieldname="AdviseThresholdYes"/>
<Data type="Entry" fieldtype="Checkbox" name="AdviseThresholdNo"
fieldname="AdviseThresholdNo"/>
<Data type="Entry" fieldtype="Checkbox" name="ConductedIMEYes"
fieldname="ConductedIMEYes"/>
<Data type="Entry" fieldtype="Checkbox" name="ConductedIMENo"
fieldname="ConductedIMENo"/>
<Data type="Entry" fieldtype="Checkbox" name="ContemplateSchedulingYes"
fieldname="ContemplateSchedulingYes"/>
<Data type="Entry" fieldtype="Checkbox" name="ContemplateSchedulingNo"
fieldname="ContemplateSchedulingNo"/>
<Data type="Entry" fieldtype="Text" name="NatureOfInjury"
fieldname="NatureOfInjury" size="30" maxlength="30"/>
<Data type="Merge" fieldtype="Text" name="AdjusterName"
fieldname="AdjusterName" size="30" maxlength="30"/>
<Data type="Merge" fieldtype="Text" name="AdjusterPhone"
fieldname="AdjusterPhone" size="30" maxlength="30"/>
</RequiredData>
</Form>

Any help would be greatly appreciated.
 
G

Guest

That's it. Thanks!!!!
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Bruce Barker said:
that becuase you add controls to

Me.Controls(1).

making them children of the first control on the page, while you add text to

Me.Controls

adding after the last control on the page.


-- bruce (sqlwork.com)


Joe said:
Hello All:

I am trying to dynamically populate a web page with literal content and
controls (textboxes and checkboxes (and eventually two buttons - the
buttons
do not appear in the code yet). I read an xml file and, using the values
retrieved from it, determine what text should be displayed and which
controls
should be rendered and - most importantly - where those controls should be
rendered.

The ultimate goal is to have some text followed by a control that will
capture the users response and post it back to the server. For example the
page might show:

Please enter the dollar amount: [textbox goes here].
Was this an accident? [checkbox for yes] Yes [checkbox for no] No

The problem is that all of the controls are rendered at the top of the
page
and all of the text renders after the closing html tag. I don't know why
this is and I don't know enough about the Render method to speak
intelligently about it. I hope that I have explained clearly what I am
trying to do. If not please let me know.

The code is here:

Structure DynamicControl
Dim Type As String
Dim FieldType As String
Dim Name As String
Dim FieldName As String
Dim Size As String
Dim MaxLength As String
Dim EntryType As String
End Structure

Private doc As XmlDocument
Private Lines As XmlNodeList
Private ReqData As XmlNodeList

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Response.BufferOutput = True
Dim Line As XmlNode
Dim ChildNode As XmlNode
Dim DynamicEntry As XmlNode

output = New HtmlTextWriter(txtWtr)

doc = New XmlDocument
doc.Load("C:\SampleForm.xml")

Lines = doc.GetElementsByTagName("Line")
ReqData = doc.GetElementsByTagName("Data")

For Each Line In Lines
If Line.HasChildNodes Then
For Each ChildNode In Line.ChildNodes
Dim attrList As XmlAttributeCollection =
ChildNode.Attributes
If Not (attrList Is Nothing) Then
Dim DynCtl As DynamicControl =
ParseDynamicCtrlData(attrList.GetNamedItem("id").Value)

Select Case DynCtl.FieldType.ToLower
Case "checkbox"
Dim c As CheckBox = New CheckBox
c.ID = attrList.GetNamedItem("id").Value
c.Text = DynCtl.Name
Me.Controls(1).Controls.Add(c)

Case "text"
Dim t As TextBox = New TextBox
t.ID = attrList.GetNamedItem("id").Value
t.MaxLength = CType(DynCtl.MaxLength,
Integer)
t.Text = DynCtl.Name
Me.Controls(1).Controls.Add(t)

End Select
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
End Sub

Private Function ParseDynamicCtrlData(ByVal id As String) As
DynamicControl
Dim DataNode As XmlNode
Dim dc As DynamicControl

For Each DataNode In ReqData
If String.Compare(DataNode.Attributes("name").Value, id) = 0
Then
dc.FieldType = DataNode.Attributes("fieldtype").Value
If dc.FieldType.ToLower = "text" Then
If String.Compare(DataNode.Attributes("type").Value,
"merge") <> 0 Then
dc.FieldName =
DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value
dc.Size = DataNode.Attributes("size").Value
dc.MaxLength =
DataNode.Attributes("maxlength").Value
End If

ElseIf dc.FieldType.ToLower = "checkbox" Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value

End If
Exit For
End If
Next

Return dc
End Function

The XML is here:

<Form>
<Content>
<Line><Dynamic type="text" id="DateField"/></Line>
<Line/>
<Line><Dynamic type="text" id="CustomAddress1"/></Line>
<Line><Dynamic type="text" id="CustomAddress2"/></Line>
<Line><Dynamic type="text" id="CustomAddress3"/></Line>
<Line><Dynamic type="text" id="CustomAddress4"/></Line>
<Line/>
<Line/>
<Line>RE: Your File #: <Dynamic type="text" id="YourFile"/></Line>
<Line> Your Insured: <Dynamic type="text"
id="YourInsured"/></Line>
<Line> Our File #: <Dynamic type="text" id="OurFile"/></Line>
<Line> Our Insured: <Dynamic type="text" id="OurInsured"/></Line>
<Line> Date of Loss: <Dynamic type="text" id="DateOfLoss"/></Line>
<Line/>
<Line>We are asking you to please complete the following with regard to
your No-Fault file on the above mentioned insured.</Line>
<Line/>
<Line>Medical paid: <Dynamic type="text" id="MedicalPaid"/></Line>
<Line>Wage Loss paid: <Dynamic type="text" id="WageLossPaid"/></Line>
<Line>Essential Services paid: <Dynamic type="text"
id="EssentialServicesPaid"/></Line>
<Line>Advise if threshold passed: <Dynamic
type="checkbox" id="AdviseThresholdYes"/> Yes <Dynamic type="checkbox"
id="AdviseThresholdNo"/> No</Line>
<Line>Have you conducted an IME at this time? <Dynamic
type="checkbox" id="ConductedIMEYes"/> Yes <Dynamic
type="checkbox" id="ConductedIMENo"/> No</Line>
<Line>If not, do you contemplate scheduling one? <Dynamic
type="checkbox" id="ContemplateSchedulingYes"/> Yes <Dynamic
type="checkbox" id="ContemplateSchedulingNo"/> No</Line>
<Line>Nature of injury <Dynamic type="text" id="NatureOfInjury"/></Line>
<Line>We thank you for your cooperation and are enclosing a return
envelope
for your convenience.</Line>
<Line/>
<Line>Sincerely,</Line>
<Line/>
<Line/>
<Line/>
<Line/>
<Line><Dynamic type="text" id="AdjusterName"/></Line>
<Line><Dynamic type="text" id="AdjusterPhone"/></Line>
<Line/>
<Line>Claims Department</Line>
<Line/>
<Line/>
<Line>WB-204 (12-99)</Line>
</Content>
<RequiredData>
<Data fieldtype="NowDate" name="DateField"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress1"
fieldname="CustomAddress1" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress2"
fieldname="CustomAddress2" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress3"
fieldname="CustomAddress3" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress4"
fieldname="CustomAddress4" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="YourFile" fieldname="YourFile"
size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="YourInsured"
fieldname="YourInsured" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="OurFile" fieldname="OurFile"
size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="OurInsured"
fieldname="OurInsured" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="DateOfLoss"
fieldname="DateOfLoss" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="MedicalPaid"
fieldname="MedicalPaid" size="30" maxlength="20" entrytype="Numeric"/>
<Data type="Entry" fieldtype="Text" name="WageLossPaid"
fieldname="WageLossPaid" size="30" maxlength="20" entrytype="Numeric"/>
<Data type="Entry" fieldtype="Text" name="EssentialServicesPaid"
fieldname="EssentialServicesPaid" size="30" maxlength="20"
entrytype="Numeric"/>
<Data type="Entry" fieldtype="Checkbox" name="AdviseThresholdYes"
fieldname="AdviseThresholdYes"/>
<Data type="Entry" fieldtype="Checkbox" name="AdviseThresholdNo"
fieldname="AdviseThresholdNo"/>
<Data type="Entry" fieldtype="Checkbox" name="ConductedIMEYes"
fieldname="ConductedIMEYes"/>
<Data type="Entry" fieldtype="Checkbox" name="ConductedIMENo"
fieldname="ConductedIMENo"/>
<Data type="Entry" fieldtype="Checkbox" name="ContemplateSchedulingYes"
fieldname="ContemplateSchedulingYes"/>
<Data type="Entry" fieldtype="Checkbox" name="ContemplateSchedulingNo"
fieldname="ContemplateSchedulingNo"/>
<Data type="Entry" fieldtype="Text" name="NatureOfInjury"
fieldname="NatureOfInjury" size="30" maxlength="30"/>
<Data type="Merge" fieldtype="Text" name="AdjusterName"
fieldname="AdjusterName" size="30" maxlength="30"/>
<Data type="Merge" fieldtype="Text" name="AdjusterPhone"
fieldname="AdjusterPhone" size="30" maxlength="30"/>
</RequiredData>
</Form>

Any help would be greatly appreciated.
 
G

Guest

Never mind. Can use
Dim plc as Placeholder = new Placeholder
Me.controls(1).controls.add(plc) as needed.

BTW, do you know why the Form is Control(1) and not Control(0)?

TIA. Apprecaite your efforts.
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Curt_C said:
http://aspnet.4guysfromrolla.com/articles/081402-1.aspx
http://www.devx.com/codemag/Article/20144/0/page/2

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



Joe said:
Curt,

The issue is that I have never used a placeholder before. I have no
experience with them. That's why I am asking for an example.
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Curt_C said:
1) Read your XML in, DataSet might be easiest.
2) Bind your repeater to it
3) in the data bound event write your control to the place holder

There are plenty of samples out there of the Repeater, if that's where you
are saying you are stuck...
I'm trying to not write it for you and instead have you try and post the
specific issues/problems that you encounter.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



:

Sorry Curt. I really need you to spell this one out....

How would you implment this? In code? In the markup? Both?

The key here is explicitly spelling out each part of the solution that you
are recommending.

Thanks,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


:

<repeater>
<placeholder for control>
<placeholder for text for question>
</repeater>

The repeater is bound to the XML list for it's iteration/count

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



:

I am not following you. Would you be willing to clarify "repeater perhaps?"
How about an example?
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


:

Repeater perhaps.


--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



:

Curt,

Since I will have no idea how many controls I am adding for a given page
(that is determined by the xml), how would I handle the ambiguity of not
knowing how many placeholders to add?

--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


:

if I read it right you are simply adding the controls to the page, but not
specifying where.
You may want to look at the placeholder to use to add your controls to.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



:

Hello All:

I am trying to dynamically populate a web page with literal content and
controls (textboxes and checkboxes (and eventually two buttons - the buttons
do not appear in the code yet). I read an xml file and, using the values
retrieved from it, determine what text should be displayed and which controls
should be rendered and - most importantly - where those controls should be
rendered.

The ultimate goal is to have some text followed by a control that will
capture the users response and post it back to the server. For example the
page might show:

Please enter the dollar amount: [textbox goes here].
Was this an accident? [checkbox for yes] Yes [checkbox for no] No

The problem is that all of the controls are rendered at the top of the page
and all of the text renders after the closing html tag. I don't know why
this is and I don't know enough about the Render method to speak
intelligently about it. I hope that I have explained clearly what I am
trying to do. If not please let me know.

The code is here:

Structure DynamicControl
Dim Type As String
Dim FieldType As String
Dim Name As String
Dim FieldName As String
Dim Size As String
Dim MaxLength As String
Dim EntryType As String
End Structure

Private doc As XmlDocument
Private Lines As XmlNodeList
Private ReqData As XmlNodeList

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Response.BufferOutput = True
Dim Line As XmlNode
Dim ChildNode As XmlNode
Dim DynamicEntry As XmlNode

output = New HtmlTextWriter(txtWtr)

doc = New XmlDocument
doc.Load("C:\SampleForm.xml")

Lines = doc.GetElementsByTagName("Line")
ReqData = doc.GetElementsByTagName("Data")

For Each Line In Lines
If Line.HasChildNodes Then
For Each ChildNode In Line.ChildNodes
Dim attrList As XmlAttributeCollection =
ChildNode.Attributes
If Not (attrList Is Nothing) Then
Dim DynCtl As DynamicControl =
ParseDynamicCtrlData(attrList.GetNamedItem("id").Value)

Select Case DynCtl.FieldType.ToLower
Case "checkbox"
Dim c As CheckBox = New CheckBox
c.ID = attrList.GetNamedItem("id").Value
c.Text = DynCtl.Name
Me.Controls(1).Controls.Add(c)

Case "text"
Dim t As TextBox = New TextBox
t.ID = attrList.GetNamedItem("id").Value
t.MaxLength = CType(DynCtl.MaxLength, Integer)
t.Text = DynCtl.Name
Me.Controls(1).Controls.Add(t)

End Select
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
End Sub

Private Function ParseDynamicCtrlData(ByVal id As String) As
DynamicControl
Dim DataNode As XmlNode
Dim dc As DynamicControl

For Each DataNode In ReqData
If String.Compare(DataNode.Attributes("name").Value, id) = 0 Then
dc.FieldType = DataNode.Attributes("fieldtype").Value
If dc.FieldType.ToLower = "text" Then
If String.Compare(DataNode.Attributes("type").Value,
"merge") <> 0 Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value
dc.Size = DataNode.Attributes("size").Value
dc.MaxLength = DataNode.Attributes("maxlength").Value
End If

ElseIf dc.FieldType.ToLower = "checkbox" Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value

End If
Exit For
End If
Next

Return dc
End Function

The XML is here:

<Form>
<Content>
<Line><Dynamic type="text" id="DateField"/></Line>
<Line/>
<Line><Dynamic type="text" id="CustomAddress1"/></Line>
<Line><Dynamic type="text" id="CustomAddress2"/></Line>
<Line><Dynamic type="text" id="CustomAddress3"/></Line>
<Line><Dynamic type="text" id="CustomAddress4"/></Line>
<Line/>
<Line/>
<Line>RE: Your File #: <Dynamic type="text" id="YourFile"/></Line>
<Line> Your Insured: <Dynamic type="text" id="YourInsured"/></Line>
<Line> Our File #: <Dynamic type="text" id="OurFile"/></Line>
<Line> Our Insured: <Dynamic type="text" id="OurInsured"/></Line>
<Line> Date of Loss: <Dynamic type="text" id="DateOfLoss"/></Line>
<Line/>
<Line>We are asking you to please complete the following with regard to
your No-Fault file on the above mentioned insured.</Line>
<Line/>
<Line>Medical paid: <Dynamic type="text" id="MedicalPaid"/></Line>
<Line>Wage Loss paid: <Dynamic type="text" id="WageLossPaid"/></Line>
<Line>Essential Services paid: <Dynamic type="text"
id="EssentialServicesPaid"/></Line>
<Line>Advise if threshold passed: <Dynamic
type="checkbox" id="AdviseThresholdYes"/> Yes <Dynamic type="checkbox"
id="AdviseThresholdNo"/> No</Line>
<Line>Have you conducted an IME at this time? <Dynamic
type="checkbox" id="ConductedIMEYes"/> Yes <Dynamic
type="checkbox" id="ConductedIMENo"/> No</Line>
<Line>If not, do you contemplate scheduling one? <Dynamic
type="checkbox" id="ContemplateSchedulingYes"/> Yes <Dynamic
type="checkbox" id="ContemplateSchedulingNo"/> No</Line>
<Line>Nature of injury <Dynamic type="text" id="NatureOfInjury"/></Line>
<Line>We thank you for your cooperation and are enclosing a return envelope
for your convenience.</Line>
<Line/>
<Line>Sincerely,</Line>
<Line/>
<Line/>
<Line/>
<Line/>
<Line><Dynamic type="text" id="AdjusterName"/></Line>
<Line><Dynamic type="text" id="AdjusterPhone"/></Line>
<Line/>
<Line>Claims Department</Line>
<Line/>
<Line/>
<Line>WB-204 (12-99)</Line>
</Content>
<RequiredData>
<Data fieldtype="NowDate" name="DateField"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress1"
fieldname="CustomAddress1" size="30" maxlength="30"/>
<Data type="Entry" fieldtype="Text" name="CustomAddress2"
 
G

Guest

That's why I was saying use a Repeater with the PlaceHolder in the
ItemTemplate.
Then it would add (n) number of the Placeholders.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



Joe said:
Thanks Curt. I've already read these. But they don't solve the problem.
Here's why: I can't statically place "Placeholder" controls on this form. I
have no idea how many I would need or where they should go.

The controls (placehodlers or otherwise) must be dynamically added to the
form. Then they must be dynamically populated. Remember, I do not know what
content or controls will be requried for a given form. That is determined
solely by the XML.

Do you know of any articles that discuss this (dynamically adding
Placeholder controls (to be populated at some later time in the cdoe))?

Thanks,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Curt_C said:
http://aspnet.4guysfromrolla.com/articles/081402-1.aspx
http://www.devx.com/codemag/Article/20144/0/page/2

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



Joe said:
Curt,

The issue is that I have never used a placeholder before. I have no
experience with them. That's why I am asking for an example.
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


:

1) Read your XML in, DataSet might be easiest.
2) Bind your repeater to it
3) in the data bound event write your control to the place holder

There are plenty of samples out there of the Repeater, if that's where you
are saying you are stuck...
I'm trying to not write it for you and instead have you try and post the
specific issues/problems that you encounter.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



:

Sorry Curt. I really need you to spell this one out....

How would you implment this? In code? In the markup? Both?

The key here is explicitly spelling out each part of the solution that you
are recommending.

Thanks,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


:

<repeater>
<placeholder for control>
<placeholder for text for question>
</repeater>

The repeater is bound to the XML list for it's iteration/count

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



:

I am not following you. Would you be willing to clarify "repeater perhaps?"
How about an example?
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


:

Repeater perhaps.


--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



:

Curt,

Since I will have no idea how many controls I am adding for a given page
(that is determined by the xml), how would I handle the ambiguity of not
knowing how many placeholders to add?

--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


:

if I read it right you are simply adding the controls to the page, but not
specifying where.
You may want to look at the placeholder to use to add your controls to.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



:

Hello All:

I am trying to dynamically populate a web page with literal content and
controls (textboxes and checkboxes (and eventually two buttons - the buttons
do not appear in the code yet). I read an xml file and, using the values
retrieved from it, determine what text should be displayed and which controls
should be rendered and - most importantly - where those controls should be
rendered.

The ultimate goal is to have some text followed by a control that will
capture the users response and post it back to the server. For example the
page might show:

Please enter the dollar amount: [textbox goes here].
Was this an accident? [checkbox for yes] Yes [checkbox for no] No

The problem is that all of the controls are rendered at the top of the page
and all of the text renders after the closing html tag. I don't know why
this is and I don't know enough about the Render method to speak
intelligently about it. I hope that I have explained clearly what I am
trying to do. If not please let me know.

The code is here:

Structure DynamicControl
Dim Type As String
Dim FieldType As String
Dim Name As String
Dim FieldName As String
Dim Size As String
Dim MaxLength As String
Dim EntryType As String
End Structure

Private doc As XmlDocument
Private Lines As XmlNodeList
Private ReqData As XmlNodeList

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Response.BufferOutput = True
Dim Line As XmlNode
Dim ChildNode As XmlNode
Dim DynamicEntry As XmlNode

output = New HtmlTextWriter(txtWtr)

doc = New XmlDocument
doc.Load("C:\SampleForm.xml")

Lines = doc.GetElementsByTagName("Line")
ReqData = doc.GetElementsByTagName("Data")

For Each Line In Lines
If Line.HasChildNodes Then
For Each ChildNode In Line.ChildNodes
Dim attrList As XmlAttributeCollection =
ChildNode.Attributes
If Not (attrList Is Nothing) Then
Dim DynCtl As DynamicControl =
ParseDynamicCtrlData(attrList.GetNamedItem("id").Value)

Select Case DynCtl.FieldType.ToLower
Case "checkbox"
Dim c As CheckBox = New CheckBox
c.ID = attrList.GetNamedItem("id").Value
c.Text = DynCtl.Name
Me.Controls(1).Controls.Add(c)

Case "text"
Dim t As TextBox = New TextBox
t.ID = attrList.GetNamedItem("id").Value
t.MaxLength = CType(DynCtl.MaxLength, Integer)
t.Text = DynCtl.Name
Me.Controls(1).Controls.Add(t)

End Select
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
Else
Dim lit As Literal = New Literal
lit.Text = Line.InnerText & "<br/>"
Me.Controls.Add(lit)
End If
Next
End Sub

Private Function ParseDynamicCtrlData(ByVal id As String) As
DynamicControl
Dim DataNode As XmlNode
Dim dc As DynamicControl

For Each DataNode In ReqData
If String.Compare(DataNode.Attributes("name").Value, id) = 0 Then
dc.FieldType = DataNode.Attributes("fieldtype").Value
If dc.FieldType.ToLower = "text" Then
If String.Compare(DataNode.Attributes("type").Value,
"merge") <> 0 Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value
dc.Size = DataNode.Attributes("size").Value
dc.MaxLength = DataNode.Attributes("maxlength").Value
End If

ElseIf dc.FieldType.ToLower = "checkbox" Then
dc.FieldName = DataNode.Attributes("fieldname").Value
dc.Name = DataNode.Attributes("name").Value

End If
Exit For
End If
Next

Return dc
End Function

The XML is here:

<Form>
<Content>
<Line><Dynamic type="text" id="DateField"/></Line>
<Line/>
<Line><Dynamic type="text" id="CustomAddress1"/></Line>
<Line><Dynamic type="text" id="CustomAddress2"/></Line>
<Line><Dynamic type="text" id="CustomAddress3"/></Line>
<Line><Dynamic type="text" id="CustomAddress4"/></Line>
<Line/>
<Line/>
<Line>RE: Your File #: <Dynamic type="text" id="YourFile"/></Line>
<Line> Your Insured: <Dynamic type="text" id="YourInsured"/></Line>
<Line> Our File #: <Dynamic type="text" id="OurFile"/></Line>
<Line> Our Insured: <Dynamic type="text" id="OurInsured"/></Line>
<Line> Date of Loss: <Dynamic type="text" id="DateOfLoss"/></Line>
<Line/>
<Line>We are asking you to please complete the following with regard to
your No-Fault file on the above mentioned insured.</Line>
<Line/>
<Line>Medical paid: <Dynamic type="text" id="MedicalPaid"/></Line>
<Line>Wage Loss paid: <Dynamic type="text" id="WageLossPaid"/></Line>
<Line>Essential Services paid: <Dynamic type="text"
id="EssentialServicesPaid"/></Line>
<Line>Advise if threshold passed: <Dynamic
type="checkbox" id="AdviseThresholdYes"/> Yes <Dynamic type="checkbox"
id="AdviseThresholdNo"/> No</Line>
<Line>Have you conducted an IME at this time? <Dynamic
type="checkbox" id="ConductedIMEYes"/> Yes <Dynamic
type="checkbox" id="ConductedIMENo"/> No</Line>
<Line>If not, do you contemplate scheduling one? <Dynamic
type="checkbox" id="ContemplateSchedulingYes"/> Yes <Dynamic
type="checkbox" id="ContemplateSchedulingNo"/> No</Line>
<Line>Nature of injury <Dynamic type="text" id="NatureOfInjury"/></Line>
 

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

Top