Tuesday, August 4, 2009

Dynamic creation of textbox using C#

Dynamix creation of 5 textbox in windows application using C#:

int x = 10;
int y = 20;
List dynamictxt = new List();
for (int i = 0; i < 5; i++)
{
TextBox txtbox = new TextBox();
txtbox.Name = "textbox" + i.ToString();
txtbox.Location = new Point(x, y * i);
dynamictxt.Add(txtbox);
this.Controls.Add(txtbox);

}

On lost focus of textbox get the product of two textboxes in javascript.

Hi,
Please check the following code:

function Prod(input1,input2,output)
{
var first = document.getElementById(input1);
var second = document.getElementById(input2);
var third = document.getElementById(output);

third.value = first.value * second.value;
}

Use the html textboxes and on the second textbox call the function onblur

onblur="Prod('txtVal','txtVal2','txtProd');"

What’s different about switch statements in C#?

C# does not support an explicit fall through from one case label to another. If you want, you can use goto a switch-case or goto default.

case 1:
cost += 5;
break;
case 2:
cost += 10;
goto case 1;

Thursday, February 26, 2009

Reverse the elements in an Array using Javascript

Sunday, February 8, 2009

Convert string to Date.

string Strdate = "01/01/2000";
DateTime date = DateTime.Parse(Strdate);
Console.WriteLine(date.ToString());

Wednesday, July 16, 2008

singleton and singlecall.

Remoting has support for both stateless and with-state environment, which is achieved using Singleton and Singlecall activation

Singleton types never have more than one instance at any one time. If an instance exists, all client requests are serviced by that instance.
Single Call types always have one instance per client request. The next method invocation will be serviced by a different server instance, even if the previous instance has not yet been recycled by the system.

If the operations are stateless, then using a singleton or single call wont really matter.
If you have any need to retain information between calls, you might
consider a singleton, as you will be able to store state in the singleton.

Difference between web services & remoting?

Remoting and Web Services are ways of communication between applications.

In Remoting, the applications involved in the communication process may be located on the same computer, different computers in a same or different network. A proxy of an application object is created on the other application.

Web Services - Communication between applications using web services is platform independent and programming independent. The application that consumes the web service, simply accesses it, without needing to know how this web service has actually been implemented & created.
It allows Distributed Applications to share Business Logic over Internet.
Differences between both:

1.Web Service are Stateless, whereas Remoting has support for both stateless and with-state environment, which is achieved using Singleton and Singlecall activation
2.ASP.NET provides good support to create Web Services. They are easy to deploy.Remoting is little complex.
3. In Remoting the applications involved in the communication should be built on .Net.
4.ASP.NET Web Services may be accessed using HTTP only. Remoting objects may be accessed over any protocol like TCP, SMTP, HTTP.