TechBubbles

Archive for August, 2008

ASP.NET Dynamic Data Inline Editing

Introduction

This post explains how to edit the data inline in grid view control. I explained the overview on ASP.NET Dynamic Data and creating a simple Dynamic Data Web site using Scaffolding.

How to edit the inline data in Grid view

1. Open the Dynamic Data Web site that you have created in Dynamic Data Web site using Scaffolding.

2. Open the Global.asax  file it looks like

Global

The Default route will look like above highlighted area. It took the table as database table name and action is one of List,Details,Edit or Insert. Comment the default route which shown above in the screen shot.

3. There are some routing statements put in the comments below the default route, we have to  un comment the section.

Global2

 

From the above new routing statement observe that instead action it is having ListDetails page for Action List and Details. So Same page is using for listing the results and editing the data.

4. You can find the ListDetails.aspx page under PageTemplates in the Dynamic Data Web Site.

Global3

5. When execute the project we will see the following screen which is ready for inline editing when you are updating the record.

Global4

2 comments

Web slices and Accelerators in IE 8 Beta2

Introduction

The new version of Internet explorer IE 8 Beta2 providing some cool features like Web slices, Accelerators, Ajax Navigation and Developer tools. More you can find at IE 8 Beta 2 features for Developers.

Web slices in IE 8

In order to have your favorite sites up to date on your favorites is really time consuming. IE 8 brings you web slices  through which you can keep your favorite web sites up to date.

Webslices

It tracks the web site that you added to the web slices. A flash will appear when ever a update is in the site.

Subscribing to the available web slices in the web site is as simple as adding the sites to the favorites.

webslicesSub

Accelerators in IE 8

using Accelerators you can gain access to your favorite online services like searching,shopping and emailing in a click.

You  can search,map,email or translate , share content from any web page that you are currently viewing by just one click. Accelerators are being added to the IE gallery to enhance the user browser experience.

Accelerator

Select the content on the web page that you are browsing and right click on it Accelerator icon will appear as shown above with a set of options like email,map and Blog the text just by a click.

Adding Accelerators to your browser

You can add more accelerators to the browser by clicking on the Accelerator icon on the web page then find more accelerators the say add it will added to your favorite accelerators.

AcceleratorsAdding

1 comment

Internet Explorer 8 Beta 2 Features for Developers with examples

Introduction

IE 8 Beta 2 provided the decent features to the  designers and developers community. If you write the code for IE 8 Beta 2 that can run on anywhere.

It means it is allowing developers and designers to develop applications with Interoperability and web standards.

  • CSS 2.1 complainer.
  • HTML 5.0 standards supported.
  • Ajax navigation and enhancements supported. 
  • Implementing DOM storage for HTML 5.0
  1. IE 8 is different from IE 7 in AJAX enhancements and Navigations

Ajax navigation

Enables the in place navigation when you are browsing maps for a particular location you may use the zoom option in the maps. Each and every zoom action will be stored in the travel history which is highlighted in oval.

2. DOM Storage in Connectivity events

 

When you are writing BLOG post or checking an e-mail aDOMstoraget airport if suddenly connections drops then it prompts you to save the typed data on offline. Prompt is highlighted in the oval.

It also allows you cross domain communication and messaging using HTML standards.

3. More Server Connections for better performance. currently allowing 6 earlier it is 2.

4. Document mode Compatibility- No need to write any code for to render the content which is developed in earlier versions of the Internet Explorer. By placing a simple meta tag instructs the IE 8 to render the earlier browser versions content in right format. So providing full document compatibility mode.

DocumentCompatibility

If at all the content not rendered properly in beta it suggest through compatibility button in address bar to best view version.

5. IE Developer tools- allows the developer to debug the java script and in place HTML and CSS changes. (Shift + F12 ) is the keyboard short cut for opening the debugger tool.

 tools

  

The developer tool looks like

debugger

You can view the page in different IE versions using the above tool. we can call this feature as site preview.

5. Profiling the web sites-

profiler

we can check application performance and bottle necks using above built in profiler.

6. Extending the service integration through web slices and Accelerators.

    Implementing the web slices and Accelerators is easy.

 

You can download the Internet explorer 8 beta 2 for exploring the features.

2 comments

Validating XML Document Using XSD in C#.NET

Introduction

This post explains how to apply  Schema Definition Language(XSD) to Extensible Markup Language () document. Basics of XSD.

Create an Document

  1. Start Visual Studio .NET
  2. Create a new File.
  3. Add the following data to the Document
<Employee EmployeeID="123">
   <EmployeeName>James Bond</EmployeeName>
</Employee>

  4.  Save the file as Employee. file 

Create the XSD Schema, and Link to Document

1. Start Visual Studio .NET

2. Create a new empty text file

3. Add the following XSD Schema definitions to describe the document.

<? version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <xsd:element name="Employee">
      <xsd:complexType>
         <xsd:sequence>
            <xsd:element name="EmployeeName" type="xsd:string"/>
         </xsd:sequence>
         <xsd:attribute name="EmployeeID" use="required" type="xsd:int"/>
      </xsd:complexType>
   </xsd:element>
</xsd:schema>

4. Save the file as Employee.xsd 
5. Open the original Employee. file, and link it to the XSD schema as follows
<? version="1.0"?>
<Employee EmployeeID="123"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="Employee.xsd">
   <EmployeeName>Rugby jersey</EmployeeName>
</Employee>

6. Save the modified as EmployeeWithXSD..

Validate Document

1. Load the EmployeeWithXSD. using XmlTextReader as follows:

XmlTextReader r = new XmlTextReader("C:\\EmployeeWithXSD.");
XmlValidatingReader v = new XmlValidatingReader(r);
v.ValidationType = ValidationType.Schema;
v.ValidationEventHandler +=
   new ValidationEventHandler(MyValidationEventHandler);
while (v.Read())
{
   // Can add code here to process the content.
}
v.Close();

// Check whether the document is valid or invalid.
if (isValid)
   Console.WriteLine("Document is valid");
else
   Console.WriteLine("Document is invalid");
public static void MyValidationEventHandler(object sender,
                                            ValidationEventArgs args)
{
   isValid = false;
   Console.WriteLine("Validation event\n" + args.Message);
}

2. Build and run the application to use the XSD schema to validate the  

    document.

1 comment

XML Schema Basics(XSD)

Introduction

This post gives a basic overview of Schema and how to use in development. schema describes what document contains and content of the document what fields and sub elements it can contain.

Standards for Describing Document

  • DTD : was the First formulized standard.
  • XDR: Much comprehensive standard than DTD.
  • XSD: Currently de facto standard for describing the documents. There are two versions in use 1.0 and 1.1. An XSD schema it self is a document.

XSD Elements

Elements are building blocks for any document, element defines the structure of the document. The following is the syntax to define the element in XSD Schema.

Example:

<xs: element name=”abc” type=”xyz” /> 

  1. An Element must have the name property, the same will appear in the document.
  2. Type property describes about what can be contained in the element when it appears in document. eg: xs:string, xs:integer, xs:boolean or xs:date

Example:

Sample XSD

<xs:element name="Employee_dob"
                    type="xs:date"/>

Sample

<Employee_dob>
     2000-01-12T12:13:14Z
</Employee_dob>

Fixed and Default Properties

The XSD element can contain the Fixed or Default properties.

Default means that if no value specified in the document then application uses the default value specified in the XSD document.

Example:

<xs:element name="Employee_name" type="xs:string" default="unknown"/>

Fixed means the value in the document can only have the value specified in the XSD.

Example:

<xs:element name="Customer_location" type="xs:string" fixed="UK"/> 

Cardinality

Specifies how many times an element can appear can be called Cardinality. it is specified using the attributes minOccurs and maxOccurs. Both attributes can assigned a non-negative value.

The default value for minOccurs and maxOccurs is 1.

Example:

<xs:element name="Employee_hobbies"

                    type="xs:string"

                    minOccurs="2"

                    maxOccurs="10"/>

 

Employee_hobbies element must appear at least twice and not more than 10 times in the document.

 

Simple Types

We can define our own types by modifying the existing types.

example: Define a code, that may be an integer with a max limit.

<xs:element name="Employee" type="xs:string"/> 
Complex Types:  is a container for other elements which specifies child
elements an element can contain.
Example:
<xs:element name="Employee">
    <xs:complexType>
            <xs:sequence>
                <xs:element name="Dob" type="xs:date" />
                <xs:element name="Address" type="xs:string" />
            </xs:sequence>
        </xs:complexType>
</xs:element> 
  1. Created a definition for element Employee
  2. <xs:complexType> is a container for other <xs:elements>
  3. Complex type do not have the type attribute and contains the <xs:sequence> element.
  4. The sequence element specifies that document must appear in the same order they are declared in the XSD Schema.
<Employee>
    <Dob> 2000-01-12T12:13:14Z </Dob>
    <Address> 39 spring field road London </Address>
</Employee>
2 comments

Visual Studio 2008 SP1 Features

Introduction

service pack 1(SP1) and .NET Framework 3.5 SP1 offers the developers to develop rapid,responsiveness and stable applications. It allows the developers to develop applications that optimized for windows vista, SQL server, MS 2007 office system and the web.

Features Overview

  • WPF Designers
  • SQL Server 2008 support
  • ADO.NET Entity Designer
  • TFS enhancements
  • Performance enhancements

You can download the Visual Studio 2008 SP1.

Note: When you are installing on Windows Vista it fails the installation.

To Resolve this issue

1. Right-click the Sidebar icon in the notification area, at the far right of the taskbar.
2. Click "Exit".

1 comment

Creating a Dynamic Data web site using Scaffolding

Introduction

This post explains how to create a basic Web application that uses Dynamic Data. Dynamic Data provides the Web application scaffolding that enables you to build rich data-driven Web applications.

scaffolding is mechanism that enhance the functionality of the existing Framework by adding the ability to dynamically display pages based on the data model of the database.

Creating a Dynamic Data Web site

We can use web site template to create a Dynamic Data Web Site.

The following steps explains the procedure

  1. Start .
  2. Go to File menu, click New Web Site, New web site dialogue box is displayed.

Dynamic1  

3. Select the Dynamic Data Web Site Template from the above dialogue box.

4. In the Location box type the name for the web site and click ok.

Adding the Data to Web site

Add a database to the project  and create the database model

To Add the database file to project.

1. In solution explorer, Right click the App_Data folder  and click Add Existing  Item.

2. Enter the AdventureWorks_Data.mdf name location file in location box.

 

The next step is create the Data model

To create the data model using LINQ to SQL

1. Right click the solution explorer and then click Add New Item.

Linq-Sql

 

2. Click Add the following dialogue will appear

ORM

Object Relational Designer is displayed

In the O/R Designer , Click the Server Explorer link

3. From Database Explorer, under data connections, expand the database file node and then table node.

4. Drag all tables into the O\R designer. Each table represented as entity.

Register the data context

1. Open the Global.asax file.

2. model.RegisterContext(typeof(AdventureWorksDataContext),
    new ContextConfiguration() { ScaffoldAllTables = true });

3. The above line in Global.asax file registers the LINQ to SQL data context for Dynamic data web site.

Testing  Dynamic Data web site

1. In Solution explorer, right-click the Default.aspx page, and then click on view in browser.

2. The following screen shows the browse page

Dynamicdatasite

  3. Using the above site you can add/edit/delete the data in a particular table.

3 comments

WCF Sample in Visual studio 2008

Introduction

This post explains the procedure to develop the sample Service and Client  in . Get an overview on WCF and WCF Terms.

1. Start open  , Select new project option from file menu

WCF Start

2. Select the ServiceApplication template from the project templates.

3. Service describes the operations that perform in a service contract.

WCF-Service

4.Declare the service contract in Iservice.cs interface and implement in the above Service class.

WCF-Interface

5. To test this service, you will need to create a client and use it to call the

    service. You can do this using the svcutil.exe tool from the command line with

    the following syntax: Generating a client using svcutil.

  svcutil.exe http://localhost:53391/Service.svc?wsdl

WCFClient

6. The above command generates a code file and configuration file contains the client class. Add the two files to your client application and use the generated client class to call the service.

Generatedclient

7. Client class which call the service looks like

callingservice

8. The generated client configuration file looks like

ClientConfig

9. The service configuration file looks like

service-config

Conclusion

The above post explains shows the standard way to create a service and client and calling the service. The Next posts explains each feature in depth. 

3 comments

Overview of .NET Remoting

Introduction

This post provides you the overview of .NET Remoting Framework. It allows the objects to interact with one another across the application domains.

Features

  • Communication channels for transporting messages across applications
  • Formatters are used for encoding and decoding the messages. supported formatters are

                 1. Binary encoding formatter – use when performance is critical

                 2. encoding formatter = use when Interoperability is essential

  •   Object activation and life-time support

           Object activation model falls into two categories

        1.Client-activated objects

       2.Server-activated objects

Remote Objects

An object is consider to be remote when the caller of the object is in different application domain. Object has to decorate with [serializable] custom attribute or they have to implement ISerializable interface to be considered as a remote. Remote objects have to be passed by value. Any object can be changed to remote by deriving from MarshalByRefObject.

Proxy Objects

Proxy Objects are created when client activates a remote object. Proxy object acts as a representative to remote object and ensures that all calls that made on proxy are  forwarded to the remote object.

Two types of Proxy Objects

1.Transparent Proxy

2.Real Proxy

when client activates a remote object, Framework creates a local instance of TransparentProxy class. All method calls on Transparent Proxy object are intercepted by CLR and forwards the call if the remote object is in same application domain.

Real Proxy object calls are intercepted by CLR and forwards the call even the remote object is in different application domain by calling its Invoke method.

Read more

2 comments

Remoting in .NET Framework 2.0

Introduction

Remoting is  distributed application technology built in the Framework 2.0 with new features which allows the developer to build wide range of distributed applications. Overview of Remoting.

Introduced some new features in Remoting in .NET FW 20. The applications are now more secured and performanent.

Enhancement in the Channel infrastructure: The new channel IPC is introduced which enables the same box communication. It allows the communication between both server application and client application when both are in the same machine. This wont use any network layer when client and server communicate. IPC Channel is based on named pipes.

IPC channel don’t use ports unlike TCP and HTTP channels. The URI will look like ipc://test/server.rem.

.NET FW 2.0 supports three channels in communication – TCP,HTTP and IPC and it supports two formatters, Binary and SOAP.

.NET Remoting Server application can be in the following forms

  • Console application
  • Windows application
  • Windows Service
  • IIS(using HTTP and Binary Formatter)

Interface

Interface Implementation in Server Application

 

Client Application

Client 

Application Configuration file settings

 

App

We can limit the number of users by using this channel.

1 comment

Next Page »