Hi all, I am trying to create textboxes dynamically and I came across a method that does mostly what I want while searching for a solution on line. The method below is what I've found
for(int i = 0; i<boxes; i++)
TextBox tb = new TextBox();
tb.Location = new System.Drawing.Point(40, 120 + i * 20);
tb.Name = "TextBoxName" + i.ToString();
tb.Size = new System.Drawing.Size(184,20);
tb.TabIndex = i + 2;
tb.Text = String.Empty;
The problem with the above code snippet is that sending values placed inside of the created textboxes to a database is difficult because the textboxes all have the same name. If each textbox can be given a different name when it is created, it will be great. Any suggestion is greatly appreciated, thanks in advance
Would you please explain how all textboxes have same name. The loop clearly says that every textbox created has index associated with its name. First textbox name reads "TextBoxName1", second reads "TextBoxName2" and so on. Where is the issue you are facing?
The problem u have is how to access the dynamically created textboxes, isn't it
look, the code u had written actually creates a number of objects of type TextBox, and give every one a name that is 'TextBoxName1', 'TextBoxName2',.. etc
the problem here is how to access the objects created.
so, you must declare a generic dictionary of string and TextBox on the class level, means
Dictionary<string,TextBox> AllTextBoxes = new
this code will be in the class level not inside any methods.
the second step is to add a line inside the loop to add items to this dictionary, each of them consists of a key and a value, the key is the name of textbox, while the value is the textbox object created in each loop, this line will be at the end of loop,
For starter I don't think that code you posted above is for asp.net. html TextBox control don't have size and location properties (this is controlled by css class and some css styles). Second, don't you think that placing in a loop with "i" index and appending this index name, give each text box unique name?
Public Class WebService
Dim con As New dbConnection
Dim da As OleDbDataAdapter
Dim tempDT As New DataTable
Dim SQL As String
Dim rows, i As Integer
Dim DepNames As New List(Of String)
Public Function getDepartementName(ByVal prefixText As String) As String()
SQL = "select DEPARTMENT_NAME from TBLDEPARTMENT_1 where upper(DEPARTMENT_NAME) like upper('%" & prefixText & "%')"
da = New OleDbDataAdapter(SQL, con.con)
rows = tempDT.Rows.Count
If rows > 0 Then
For i = 0 To rows - 1
Catch ex As Exception
this webservice is works with ajax autocomplete extender but not with jquery
this not gives any error and not call webservice method.
I have a textbox with multiline where one can write source code and compile & run it,my requirement is to implement line number like(1,2,3...) in each new line of textbox like program editor.....Thanks & Appreciates for your reply.
A simple hack is to put a listbox to the left of the textbox and display line numbers as items in the list box. Then you change the borders of the list box and the text box to make them appear as a single control.
I am new to WCF, but I like to have them in my production project instead of web services because of greater flexibiltity of WCF.
I have this scenario: One WCF that serve 9 client of the same application (on 9 different servers). The WCF build a Barcode ad return a PNG image.
I think that the better configuration is Single instance / Multiple concurrency. I also use Async methods to reduce latency.
Note that the client instance is a singleton shared between users on the same server, maybe a check on channel status is necessary?
Actually I am a little confused reading articles on WCF: some don't talk about Channel state, factory etc. Others articles show checks on channel state and Channel factory everywhere... What I have to do to make this thing work?
Are there 9 servers and 9 clients (each running their own instance of WCF)?
Or is there only 1 WCF service and 9 different clients accessing that same instance of the WCF service?
If you are just having the WCF service build an image and do no server side logic, I would remove the WCF service all together.
If there is server side logic, then 1 instance of the WCF service is usually ideal since you only need to update the application in 1 place and the clients all get the functionality (unless the clients require an update as well).
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
Thank you for your reply.
My configuration is your second one: 1 WCF service for 9 Clients.
There is not much server logic in the WCF, but since is a generic Barcode generator placed in a context where a lot of applications could use it, I think that is a good choice to have it in WCF instead of inside the main project. I will do some benchmatks to understand better if it is an issue or not.
However, my question regards how to use (and consume) wcf: I have to declare simply:
publicstatic BarcodeServiceClient BarcodeServiceClient
if (_barcodeServiceClient == null)
_barcodeServiceClient = new BarcodeServiceClient();
Hey guys,i am having trouble with my application in terms of clearing textboxes when i change my tabs.i have one tabcontainer with 3 tabs namely "Create" "update" "Delete" in my tabcontainer1 .the code i tried: