|
I'm using revealing module pattern and knockout
js file contains viewmodel something like this
var viewmodel = function (){
model = ko.mapping.fromJS([]),
init = function(initialData) {
model = initialData;
},
save = function(data, event) {
$.ajax({
});
},
delete = function(data, event) {
$.ajax({
});
};
return{
Init : init,
Save : save,
Delete : delete
};
};
view contains script to initialize viewModel and bindings
$(document).ready(function () {
viewmodel.Init(Model.toJSON());
ko.applyBindings(viewmodel);
});
Not sure if it's the best way but it works.
- Regards - J O N
|
|
|
|
|
|
that's exactly right. .NET Model is converted into JSON object and passed on to the Init function. In the Init when we do something like this we get the exact representation of the .NET Model in a javascript object with all items as knockout observables which is nice for a two-way binding.
model = ko.mapping.fromJS(initialData);
or
model = ko.wrap.fromJS(initialData);
- Regards - J O N
|
|
|
|
|
I have a textbox with multiline, i want to implement a feature in which i click a hyperlink or button then the whole content or selected content of textbox get copy to the clipboard.
Thanks In Advance,Appreciates your help
Vinay Sinha
|
|
|
|
|
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;
panel1.Controls.Add(tb);
}
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?
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
|
|
|
|