Tuesday, March 25, 2008

Calling Javascript in Dotnet based on Button id

In aspx Page

<script language="javascript" type="text/javascript">

function Getconfirm()
{
var con=confirm("Are sure want to delete this");
var test;
if(con==false)
{
alert("test");
}
else
{
alert("test1");
}
}
</script>


<asp:Button ID="btnsubmit" runat="server" OnClick="btnsubmit_Click" />
In C# Page
protected void Page_Load(object sender, EventArgs e)
{
ScriptManager.RegisterClientScriptBlock(btnsubmit, typeof(string), "bala", "Getconfirm();", true);
}
Note:btnsubmit is control id.

Monday, March 17, 2008

Windows Communication Foundation

WCF-Windows Communication Foundation


WCF is nothing but a Distributed system. Combination of Object Oriented Architechtre and Service Oriented Architecture.


NET 3.0 comes with three main technologies in core: Windows Presentation Foundation, Windows Workflow Foundation and Windows Communication Foundation.
Windows Communication Foundation (WCF), codenamed Indigo in Microsoft, is the last generation of service oriented technologies for development. It provides all the latest means to help developers build service oriented applications. The result of service oriented design is a distributed system which runs between services and clients. Windows Communication Foundation is Microsoft infrastructure for Service Oriented architecture

Advantages

Windows Communication Foundation has some important enhancements in comparison with preceding technologies·
. It merges all older separate technologies in one place and allows you to do things easier.
· It has rich communication capabilities.
· It comes with many powerful and ready to use enterprise features.
· It can be integrated with other technologies and has great interoperability.

Fundamental Concepts

Windows Communication Foundation consists of three main concepts.
· Services: Programs that respond to clients. They can send or receive messages.
· Clients: Programs that ask for a service. They can send or receive messages.
· Intermediaries: Programs that sit between services and clients (Figure 2). They can work as a firewall or can rout messages. In all cases neither services nor clients need to be aware of intermediaries.

Architecture
Architecture of Windows Communication Foundation consists of five layers. These layers from top to down are:
· Application: In this level application is located.
· Contracts: In the second layer service, data and message contracts as well as bindings and policies are present. In this level services describe themselves to clients.
· Runtime: Behaviors are located in this layer. Runtime layer loads all services.
· Messaging: Different types of channels as well as encoders are here. This layer enables communications for services.
· Hosting: This layer is where host services in different manners, but there are two common ways to host a service. You can host a service in Internet Information Services (IIS) which is easier than the second approach and starts and stops your services automatically. The second approach is to create executable files (.EXE) for services and start and stop them manually by writing more codes.

Programming Model

Windows Communication Foundation has simple and easy to write/understand codes. It has many APIs, but beside this only a small amount of these API's is common.
There are three programming approaches in Windows Communication Foundation:
· Imperative: You use programming codes in different languages to accomplish a task.
· Configuration Based: You use configuration files to do things.
· Declarative: You use attributes to declare something.

On the other hand, you can use typed services and untyped services. In typed services you pass normal objects and data types and/or get normal objects and data types, but in untyped services you pass and get messages to work directly with messages at a lower level..

Installation
Installation of Windows Communication Foundation and its development tool is easy and consists of these steps:
· Download and install .NET Framework 3.0 RTM. I also strongly recommend you to download and install WinFX SDK as well. After this step you have all necessary API's to run Windows Communication Foundation.
· Download and install Visual Studio 2005xtensions for .NET Framework 3.0 WCF and WPF). After installing this package, you will have new project templates in your Visual Studio to start developing for Windows Communication Foundation

Sunday, March 16, 2008

verbatim literal

Another useful feature of C# strings is the verbatim literal

which is a string with a @ symbol prefix, as in @"Some string". Verbatim literals make escape sequences translate as normal characters to enhance readability. To appreciate the value of verbatim literals, consider a path statement such as "c:\\topdir\\subdir\\subdir\\myapp.exe". As you can see, the backslashes are escaped, causing the string to be less readable. You can improve the string with a verbatim literal, like this: @"c:\topdir\subdir\subdir\myapp.exe".

Cracking .NET Assemblies

Cracking .NET Assemblies

This is nice articale for cracking the .net assemblies
http://www.grimes.demon.co.uk/workshops/fusionWSCrackThree.htm#Cracking_Whidbey_Assemblies