473,387 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

adding txtbx dynamically , place holders, &formatting

LU
I have code to dynamically add more text boxes when the
user clicks the 'add another carrier' button. Problem is
it creates the text boxes within the same table row as
previously created boxes. It should create in new table
row. Code is below and if you see anything else you would
change please provide for optimization. And Thanks.

Code below.
<script runat="server">
Private Sub Page_Load
Dim intCounter As Integer
If not ispostback then
ViewState("FieldCount") = 1
'response.write ( ViewState("FieldCount") )
page1.Visible = True
page2.Visible = False
page3.Visible = False

btnPage1.Visible = False
btnPage3.Visible = False
btnPage4.Visible = False

ElseIf ViewState("FieldCount") > 1 then
response.write ( ViewState("FieldCount") )
For intCounter = 2 to ViewState("FieldCount")
AddField( intCounter)
Next
end if
End Sub

Sub AddFieldCount( s As Object, e As EventArgs)
ViewState("FieldCount") += 1
AddField( ViewState("FieldCount"))
End Sub
Sub AddField(strFieldNum As String)
Dim litLabel As LiteralControl
Dim txtTextBox As TextBox

strFieldNum = strFieldNum + 2
litLabel = New LiteralControl
litLabel.Text = "<p> " & strFieldNum & ":"
plhFields.Controls.Add( litLabel )

txtTextBox = New TextBox
txtTextBox.ID = "p2Carrier" & strFieldNum
plhFields.Controls.Add( txtTextBox )

txtTextBox = New TextBox
txtTextBox.ID = "p2PolicyNum" & strFieldNum
plhFields2.Controls.Add( txtTextBox )
txtTextBox = New TextBox
txtTextBox.ID = "p2DateM" & strFieldNum
txtTextBox.Columns="2"
plhFields3.Controls.Add( txtTextBox )

txtTextBox = New TextBox
txtTextBox.ID = "p2DateD" & strFieldNum
txtTextBox.Columns="2"
plhFields4.Controls.Add( txtTextBox )
txtTextBox = New TextBox
txtTextBox.ID = "p2DateY" & strFieldNum
txtTextBox.Columns="4"
plhFields5.Controls.Add( txtTextBox )
End Sub
</script>
<!--Second page panel-->
<asp:Panel id="page2" visible="true" runat="server">
Page 2 of 3
<table border="1" width="100%">
<tr>
<td colspan="3">
List any past carriers
</td>
</tr>
<tr>
<td>Carrier</td><td>Policy Number</td><td>Expiration
Date</td>
</tr>
<tr>
<td>1.<asp:textbox id="p2Carrier1" runat="server"/></td>
<td><asp:textbox id="p2PolicyNum1" runat="server"/></td>
<td><asp:textbox id="p2DateM1" runat="server"
Columns="2"/>/<asp:textbox id="p2DateD1" runat="server"
Columns="2"/>/<asp:textbox id="p2DateY1" runat="server"
Columns="4" /></td>
</tr>
<tr>
<td>2. <asp:textbox id="p2Carrier2" runat="server"/></td>
<td><asp:textbox id="p2PolicyNum2" runat="server"/></td>
<td><asp:textbox id="p2DateM2" runat="server"
Columns="2"/>/<asp:textbox id="p2DateD2" runat="server"
Columns="2"/>/<asp:textbox id="p2DateY2" runat="server"
Columns="4" /></td>
</tr>
<tr>
<td>3. <asp:textbox id="p2Carrier3" runat="server"/></td>
<td><asp:textbox id="p2PolicyNum3" runat="server"/></td>
<td><asp:textbox id="p2DateM3" runat="server"
Columns="2"/>/<asp:textbox id="p2DateD3" runat="server"
Columns="2"/>/<asp:textbox id="p2DateY3" runat="server"
Columns="4" /></td>
</tr>

<tr>
<td><asp:PlaceHolder id="plhFields" runat="server"/></td>
<td><asp:PlaceHolder id="plhFields2"
runat="server" /></td>
<td><asp:PlaceHolder id="plhFields3" runat="server"/> /
<asp:PlaceHolder id="plhFields4" runat="server"/> /
<asp:PlaceHolder id="plhFields5" runat="server"/> </td>
</tr>

</table>
<asp:button
text="Click here to add another carrier"
OnClick="AddFieldCount"
runat="server"
/>
</asp:Panel>
Jul 21 '05 #1
0 1242

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Robert | last post by:
I need some help with formatting some text received from a database query. I am only selecting a single row per query so the formatting will only be performed on a single row. The rows I need to...
2
by: Nikos | last post by:
<code> print start_form(-action=>'index.pl'); print p( {-align=>'center'}, span( {class=>'tip'}, "ÄéÜëåîå Ýíá áðü ôá êåßìåíá ãéá íá äéáâÜóåéò => " ),...
1
by: Gudni G. Sigurdsson | last post by:
I would like to change the forground color of a row in a Data Grid based on the value of a certain column. I am using Visual C# .NET. Is there an OnPaintRow event which I can subscribe to, or how...
4
by: codemonkey | last post by:
TIA! I would like to know if there is a way to dynamically change the colors of Subform items? I have already set in place Conditional Formatting so each row has an alernating color scheme, but...
0
by: LU | last post by:
I have code to dynamically add more text boxes when the user clicks the 'add another carrier' button. Problem is it creates the text boxes within the same table row as previously created boxes. ...
9
by: Neo Geshel | last post by:
I have strip-mined, strip-searched, and completely exhausted the Internet (up to the 30th page on Google, with 100 results per page!!), all without finding an answer to my question AS TO WHY IT...
10
by: sara | last post by:
Hi - I have a report that is 14 columnar sub-reports (Line up: Position- holders in each of our 14 locations - Manager, Assistant Manager, Receiving, Office, etc). I output directly to PDF...
30
by: Medvedev | last post by:
i see serveral source codes , and i found they almost only use "new" and "delete" keywords to make they object. Why should i do that , and as i know the object is going to be destroy by itself at...
30
by: Ivan Reborin | last post by:
Hello everyone, I was wondering if anyone here has a moment of time to help me with 2 things that have been bugging me. 1. Multi dimensional arrays - how do you load them in python For...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.