S
Scott Schluer
Hello,
I have a section of code that, once filled out and the page is posted back,
needs to repeat to allow a user to enter another set of data. Basically,
once a user fills out this small section of code, another of the exact same
set of fields should appear to allow them to enter another. This should
continue as long as they need it to. I have it set up for a single entry.
How do I dynamically add new sections of code on postback (there will be a
button, which does not yet exist which will handle the "Save and add new
dependent" event). Here's the code I have for this part. Any explanations or
links to more information are appreciated.
Thanks!
Scott
---- THIS ONLY DISPLAYS ONCE, AS A HEADER
<p><br>
List the dependents you can claim on your tax return:<br>
<span id="set5">If you complete the following, additional spaces will
appear.</span>
</p>
---- THIS SECTION NEEDS TO SAVE ENTERED DATE, THEN DYNAMICALLY ADD ANOTHER
SECTION OF THE EXACT SAME CODE WHEN A USER FILLS IT OUT AND FIRES EVENT
<p>
First Name Relationship Age<br>
<asp:TextBox ID="txtDependent" Width="208" Runat="server"
/><asp:RequiredFieldValidator ID="rfv_txtDependent"
ControlToValidate="txtDependent" CssClass="InvalidField" Display="Dynamic"
EnableClientScript="False" ErrorMessage=" Required Field"
Runat="server" /><br>
Does this person live with you?
<asp:RadioButtonList ID="rdoDependentLiveWithYou"
RepeatDirection="Horizontal" Runat="server">
<asp:ListItem Value="No" >No</asp:ListItem>
<asp:ListItem Value="Yes">Yes</asp:ListItem>
</asp:RadioButtonList>
<asp:CustomValidator ID="cv_DependentLiveWithYou" CssClass="ErrorMessage"
Display="Dynamic" EnableClientScript="False" ErrorMessage=" Required
Field" OnServerValidate="Dependent_Validate" Runat="server" />
</p>
In the code-behind:
Public Sub Dependent_Validate(ByVal obj As Object, ByVal e As
ServerValidateEventArgs)
e.IsValid = False
Dim LI As ListItem
For Each LI In rdoDependentLiveWithYou.Items
If (LI.Selected) Then
e.IsValid = True
Exit Sub
End If
Next
End Sub
I have a section of code that, once filled out and the page is posted back,
needs to repeat to allow a user to enter another set of data. Basically,
once a user fills out this small section of code, another of the exact same
set of fields should appear to allow them to enter another. This should
continue as long as they need it to. I have it set up for a single entry.
How do I dynamically add new sections of code on postback (there will be a
button, which does not yet exist which will handle the "Save and add new
dependent" event). Here's the code I have for this part. Any explanations or
links to more information are appreciated.
Thanks!
Scott
---- THIS ONLY DISPLAYS ONCE, AS A HEADER
<p><br>
List the dependents you can claim on your tax return:<br>
<span id="set5">If you complete the following, additional spaces will
appear.</span>
</p>
---- THIS SECTION NEEDS TO SAVE ENTERED DATE, THEN DYNAMICALLY ADD ANOTHER
SECTION OF THE EXACT SAME CODE WHEN A USER FILLS IT OUT AND FIRES EVENT
<p>
First Name Relationship Age<br>
<asp:TextBox ID="txtDependent" Width="208" Runat="server"
/><asp:RequiredFieldValidator ID="rfv_txtDependent"
ControlToValidate="txtDependent" CssClass="InvalidField" Display="Dynamic"
EnableClientScript="False" ErrorMessage=" Required Field"
Runat="server" /><br>
Does this person live with you?
<asp:RadioButtonList ID="rdoDependentLiveWithYou"
RepeatDirection="Horizontal" Runat="server">
<asp:ListItem Value="No" >No</asp:ListItem>
<asp:ListItem Value="Yes">Yes</asp:ListItem>
</asp:RadioButtonList>
<asp:CustomValidator ID="cv_DependentLiveWithYou" CssClass="ErrorMessage"
Display="Dynamic" EnableClientScript="False" ErrorMessage=" Required
Field" OnServerValidate="Dependent_Validate" Runat="server" />
</p>
In the code-behind:
Public Sub Dependent_Validate(ByVal obj As Object, ByVal e As
ServerValidateEventArgs)
e.IsValid = False
Dim LI As ListItem
For Each LI In rdoDependentLiveWithYou.Items
If (LI.Selected) Then
e.IsValid = True
Exit Sub
End If
Next
End Sub