|
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?
Thanks & Regards,
Vani Kulkarni
|
|
|
|
|
why dont u provide id of the texbox:
tb.ID="txtBox" + i;
u just pick id for your any operation.It will be unique.
I have replied as much i understand your problem.
|
|
|
|
|
The problem u have is how to access the dynamically created textboxes, isn't it
ok
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
Dictionary<string,TextBox> ();
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,
AllTextBoxes.Items.Add("TextBoxName" + i.ToString(), tb);
now, u can access any textboxe through the dictionary when giving the name of textbox like this
string aaa = AllTextBoxes["TextBoxName1"].Text;
I hope this is usefull
Dr Sayed Tohamy, Egypt
|
|
|
|
|
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?
No more Mister Nice Guy... >: |
|
|
|
|
|
Take a look at the properties IsNamingContainer - then tweak how you're adding the text boxes, then FindControl will more than likely look attractive
C# has already designed away most of the tedium of C++.
|
|
|
|
|
|
|
Classic car or Sports car?
Which one do you want?
why?
- Regards - J O N
|
|
|
|
|
|
Because gas is expensive? :p
No more Mister Nice Guy... >: |
|
|
|
|
|
Help me
I am using jquery ui autocomplete but it's not working
i write this code
web page
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<link href="./Script/jquery-ui-1.8.1.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="./Script/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="./Script/jquery-ui-1.8.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("tbAuto").autocomplete({
source: function(request, response){
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "WebService.asmx/getDepartementName",
data: "{'Name':'" + request.term +"'}",
dataType: "json",
async: true,
success: function(data){
response(data.d);
},
error: function(result){
alert(result);
}
});
},
minLength: 1
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div class="demo">
<div class="ui-widget">
<label for="tbAuto">department name :<asp:TextBox ID="tbAuto" runat="server"></asp:TextBox> </label>
</div>
</div>
</form>
</body>
</html>
web service -
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Data
Imports System.Data.OleDb
Imports System.Web.Script.Services
Imports System.Collections.Generic
<ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class WebService
Inherits System.Web.Services.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)
<WebMethod()> _
Public Function getDepartementName(ByVal prefixText As String) As String()
Try
con.connect()
SQL = "select DEPARTMENT_NAME from TBLDEPARTMENT_1 where upper(DEPARTMENT_NAME) like upper('%" & prefixText & "%')"
da = New OleDbDataAdapter(SQL, con.con)
da.Fill(tempDT)
rows = tempDT.Rows.Count
If rows > 0 Then
For i = 0 To rows - 1
DepNames.Add(tempDT.Rows(i)(0))
Next
End If
Return DepNames.ToArray()
Catch ex As Exception
Throw ex
End Try
End Function
this webservice is works with ajax autocomplete extender but not with jquery
this not gives any error and not call webservice method.
thanks
|
|
|
|
|
Did you debug and see the execution flow?
Just a thought, may be the URL provides is not properly formed/resolved.
|
|
|
|
|
You have to build and return a json formated string back to the jquery in the client side, and in the jquery, you have to parse the json response(data.d); and populate the textbox.
So your sending to the web service, and perhaps the client is receiving, debug your web service, and test the return value in a json validator before fixing the client side.
|
|
|
|
|
I bet this service is returning xml.
Read about json enabled wcf service and use that for this.
No more Mister Nice Guy... >: |
|
|
|
|
|
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.
For more advanced uses, you need to create your own custom control like ICSharpCode.TextEditor[^] or AvalonEdit[^]
|
|
|
|
|
There is no direct way or a control that does what you seek. You have to develop your own control for such behavior.
|
|
|
|
|
|
Hi,
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?
Thank you!
NOTE: using framework 3.5
|
|
|
|
|
It is a little unclear as to what the setup is.
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:
public static BarcodeServiceClient BarcodeServiceClient
{
get
{
if (_barcodeServiceClient == null)
{
_barcodeServiceClient = new BarcodeServiceClient();
}
return _barcodeServiceClient;
}
}
OR I have to manage channels?
|
|
|
|
|
You shouldn't have to manage channels. You only need to if you are trying to use features of channels.
Look up some basic WCF articles here on CodeProject. You are basically just trying to execute a remote method. That is very straight forward with WCF.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
|
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:
protected void tabContainer1_ActiveTabChanged(object sender, EventArgs e)
{
if (tabContainer1.ActiveTabIndex == 0)
{
txtCompanyname.text="";
}
am i doing something wrong?
also 1 more problem i have is that my gridview is stretching out of my page,any way around this guys?
Thanks Smile |
|
|
|
|
|
Your event is probably firing twice, the first one clears the textbox, and the second populates the textbox in onload
You have to seperate code that runs on postback, from code that runs on onload, using
page.ispostback
So when a page loads, if not page.ispostback
When a page postback to the server, if page.ispostback
|
|
|
|