Convert Date Formats :

  • 1

Convert Date Formats :

 

//For ex., Convert MM/dd/YYYY to dd/MM/yyyy

string date = “03/27/2008”; //format is MM/dd/yyyy

DateTimeFormatInfo dateTimeFormatterProvider = DateTimeFormatInfo.CurrentInfo.Clone() as DateTimeFormatInfo;

dateTimeFormatterProvider.ShortDatePattern = “MM/dd/yyyy”; //source date format

DateTime dateTime = DateTime.Parse(date, dateTimeFormatterProvider);

string formatted = dateTime.ToString(“dd/MM/yyyy”); //write the format in which you want the date tobe converted

Response.Write(“<br />” + formatted);


Bookmark and Share


  • 0

Maintaining Fck editor value during postbacks

Here is the code to maintain value of FckEditor value during postbacks,

 

Write in Page_Load event,

 

Page.ClientScript.RegisterOnSubmitStatement(

fckContentPage.GetType(),

“fckContentPage”,

“FCKeditorAPI.GetInstance(‘” + fckContentPage.ClientID + “‘).UpdateLinkedField();”);

 

Here fckContentPage is ID of FckEditor


Bookmark and Share


  • 0

Boxing and UnBoxing

 

 

Boxing and unboxing enable value types to be treated as objects. Boxing a value type packages it inside an instance of the Object reference type. This allows the value type to be stored on the garbage collected heap. Unboxing extracts the value type from the object. In this example, the integer variable i is boxed and assigned to object o.

int i = 123;
object o = (object)i;  // boxing

The object o can then be unboxed and assigned to integer variable i

o = 123;
i = (int)o;  // unboxing

 

Performance

In relation to simple assignments, boxing and unboxing are computationally expensive processes. When a value type is boxed, an entirely new object must be allocated and constructed.This can take up to 20 times longer than an assignment.  To a lesser degree, the cast required for unboxing is also expensive computationally. When unboxing, the casting process can take 4 times as long as an assignment. For more information, see Performance.

 

 

 


Bookmark and Share


  • 0

SingleTon Object

Introduction

Sometime we need a class that has to be instantiated only once. That means we cannot have more than one instance for a class. Here singleton comes into picture. Singleton object is not a new thing come from oops concept. Let us read how easy it is.

Implementation

Typically every class is instantiated using constructor. Suppose if you make the access modifier of constructor to private, what happens u cannot access the constructor outside the class. That means u cannot instantiate your class. Then now you may have a doubt that how can we access the methods in that class without an instance. So for that you are creating one static method inside the class, I think now you got an idea. Yes, how can we access static method in a class? Directly using (classname.Methodname).
In the same way we are using our static method in our class. That static method is of class type it belongs. That means we are returning class object from static method. In this way we are restricting our class to single instanced class.

Example

This gives some clarification.public class MySingletonClass
{
//////// declarations

private string _name;
private string _company;
private static MySingletonClass singletonobject = new MySingletonClass();

//////// here some properties
public string Name
{
get
{
return _name;
}
set
{
_name = value;
}
}

public string Company
{
get
{
return _company;
}
set
{
_company = value;
}
}

///// here private constructor

private MySingleTonClass()
{
_name = “Phani”;
_company = “KST”;
}

public static MySingletonClass GetSingletonObject()
{
return singletonobject;

}

}

that’s all now u create singleton object in your application like this

MySingletonObject singleton = MySingletonObject.GetSingletonObject();
singleton.Name = “Phanindra”;
singleton.Company = “KST”;

 

 

 

 

Summary

This article describes what singleton object is and how can we make it ? and these
Singleton objects are mainly used as session objects. Just directly assign this reference
To System.Web.HttpContext.Current.Session[“SingletonSession”] = singleton;

Que : Which of the following is a Singleton object

             DataReader,SqlConnetion,SqlDataAdapter,DataSet

Ans :  DataReader

An instance of the DataReader cannot be created like DataReader dr=new DataReader() but only like DataReader dr=cmd.ExecuteReader() which returns an open datareader , this is to restrict only one instance of the dr per execution as the datareader has the behavior of exclusively locking up db connections until it reads all the records

 Courtesy: The Seo Guru, A Software Development Company, Best OOPS Blog Site, Link Submission, Thanks to Shopping  Site for Link Exchanging


Bookmark and Share


  • 0

Introduction to .NET Remoting – Part [1]

Click Here to visit our website

Welcome to the world of Distributed Application!

The article will give you introduction to the world of Distributed Application development and its respective technologies.

What is Remoting?

Remoting” is the process of programs interacting across certain boundaries. The boundaries are either different processes or different machines. In .NET Framework, Remoting can be called the foundation of distributed application.

Remoting implementation generally distinguishes between Remote Objects and Mobile Objects.

Remote Object” provides the facility to execute methods on remote servers. You can pass parameters as well as return values. The “Remote Object” will always “Stay” at server and only a reference to it will be passes around other machines / processes.

While “Mobile Objects” passes the boundary, they are serialized in to some general representation – XML – and then deserialized to the other boundary involved in the process. Both the processes – server and client – hold the copies of the same object. Method execution will always be carried out in local context boundary, and no message will travel back to the process from where the object is actually originated. We can say, there is no distinction between a server object and a client object.

Scenarios for .NET Remoting

I mean, why Remoting comes into picture?

At the beginning of Client/Server era, Remoting was mostly used to access Server Resources; as each database or file server has an implementation which allow code to be executed remotely.

Now-a-days, it’s quite feasible building a distributed application among various machines to improve performance, scalability and maintainability using Remoting.

  • Centralized Business Logic

One of key scenario for remoting implementation is the concentration of business logic on one or more central servers. This simplifies the maintainability and operability of a large-scale application. Because any changes in business logic do not entail you to roll out the application at all user’s end – you just have to update one single server only.

Thus, in this scenario; we need a technique which can be used to communicate in between two process / context boundaries that is the program or process running at user end and another one is running at business server.

  • Physical Separation of Layers

The security is the common concern in web-enabled business. So, general recommendation is against for directly connecting from web server to database server. Instead of that, we used to have one application server / business server as discussed above.

  • Accessing Other Platforms

You will commonly encounter a heterogeneous combination of different platforms, frameworks and programming languages. It is uncommon to find that a bunch of tools, programming languages have been used and implemented to develop an application for a mid-to-large scale enterprise.

Integrating these systems can be a daunting task. Remoting architecture is an absolute necessity in large scale enterprise application integration.

  • Third Party Access

Opening your system for third party access in a business-to-business environment is quite common now-a-days. Application like online Order-entry, which allows third party to place orders from one system to other, is one good example of an application utilizing remoting architecture. More application examples are – address verification system, online price comparison, distributed visitor guard house application etc.

Click Here to visit our website


Bookmark and Share


  • 0

ASP.NET 3.5, AJAX and WebServices

Introduction

This article explains the use of webservices in ASP.NET 3.5 AJAX environment and it tells how to call web service methods from a client-side javascript. It also outlines the new System.Web.Script namespace and explores the ways of defining the client-call to a web service method.


read more… ….


Bookmark and Share