473,386 Members | 1,785 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,386 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>
Nov 22 '05 #1
0 832

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'}, "ÄéÜëåîå Ýíá áðü ôá êåßìåíá ãéá íá äéáâÜóåéò => " ),...
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. ...
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...
5
by: Neo Geshel | last post by:
Greetings. I am in a very big pickle. I am trying to add page content - as well as a submit button - programatically to a web form that is supposed to submit to DB and then refresh. That...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.