Posts

Showing posts from June 14, 2009

Introduction to Web Parts in ASP.NET 2.0

Image
Summary Webparts provide us with an easy way to customize our website on runtime. Aside from their availability in Sharepoint portal server, webparts were introduced in asp.net 2.0. I have tried to cover all the common aspects of webparts in this article, like using different types of webparts and using a custom database. Introduction It would not be wrong to say that web parts are going to be the future of web based management systems. Web parts give us the option to drag and drop objects on a page, change titles, border style, and properties of objects at runtime. Before the introduction of web parts it used to be a hectic task because we had to write a lot of java script and to save the state of contents in a database. There are two basic things in web parts: Web part manager. Web part zones. Web Part Manager Web part manager is a manager for web parts behind the scenes. We normally don't do a lot of things with the web part manager either in code or

Beginning Ajax and ASP.NET 3.5

Image
More articles in ASP.NET Ajax is a great helper to us while developing rapid applications without worrying us at power of asynchronous. In Visyal Web Developer 2008 comes with builtin Atlas and ASP.NET3.5 . In this tutorial, I try to show you what's ajax and database querying at same time. Now let's build our scene. Open an empty web site and dop a ScriptManager and UpdatePanel from Ajax Extensions tab. Close the tab and open standard controls and drop one textbox and one button. Place a label inside ajax control and one more outside of UpDatePanel. The second label will display that we are using Ajax and page is not posting back. I will add some hard codes and I have put s SqlDataSource and a GridView. Complete code is below. What's going on! I'm sure that, you're thinking that that was too easy. We have just write a scene for Visual Web Developer and place all actors on board. When we start application, first label (outside of Ajax Control) w

ASP.NET AJAX in .NET 3.5 and VS 2008

Image
In the past I've blogged about the JavaScript and AJAX improvements with VS 2008 JavaScript Intellisense and VS 2008 JavaScript debugging . Below are a few notes about some of the ASP.NET AJAX runtime features coming as part of the VS 2008 and .NET 3.5 release, as well as important notes to read if you are opening existing ASP.NET AJAX 1.0 projects in VS 2008. ASP.NET AJAX included in .NET 3.5 ASP.NET AJAX 1.0 shipped as a separate download that you could install on top of ASP.NET 2.0. Starting with the .NET Framework 3.5 release, all of these features are built-in with ASP.NET, which means you no longer have to download and install a separate ASP.NET AJAX setup when building or deploying applications. When you create a new ASP.NET application or web-site in VS 2008 that targets the .NET 3.5 framework, VS will automatically add the appropriate AJAX registrations in your web.config file and the core ASP.NET AJAX server controls will show up in your toolbox. The v

Silverlight Business Application

Introduction Business Application is a template available when you install RIA services into your system. It carries two assemblies as System.Windows.RIA and System.Windows.RIA.Controls . And it adds two Silverlight Templates to VS 2008. One of them is Silverlight Navigation application and Silverlight Business Application. Here we are going to see Silverlight Business Application . Silverlight Business Application The basic addition in this template we can see is the User Authentication. That is login and logout functionality. As you can see on top right corner, login is displayed in the following figure. See full detail: http://www.c-sharpcorner.com/UploadFile/dpatra/SilverlightBusinessApplication05232009063803AM/SilverlightBusinessApplication.aspx

Silverlight 2 Web Service Part III - Single object Get and Update from database

Adding database calls This example builds on a previous tutorial: Silverlight 2 Web Service Part II - User Defined Type; the project files for this tutorial is included in the ZIP file. We are now going to expand the Silverlight application and Web Service that we created in the previous tutorial. We will make a few modifications to the user interface and add database functionality to the Web Service. In the previous tutorial we returned a static product from the Web Service, in this tutorial we are going to access a database and use products from a table called SalesLT.Product in the AdventureWorksLT database. You can download the database from the following site http://www.codeplex.com/MSFTDBProdSamples/ . See full detail: http://www.c-sharpcorner.com/UploadFile/ReefDweller/Silverlight2WebServicePartIII-SingleObjectGetAndUpdateFromDatabase06032009114325AM/Silverlight2WebServicePartIII-SingleObjectGetAndUpdateFromDatabase.aspx

Silverlight Navigation Application

Introduction Navigation Application is a template available when you install RIA services into your system. It carries two assemblies as System.Windows.RIA and System.Windows.RIA.Controls . And it adds two Silverlight Templates to VS 2008. One of them is Silverlight Navigation application and Silverlight Business Application. Here we are going to see Silverlight Navigation Application . Silverlight Navigation Application The basic addition in this template we can see is the Navigation between different pages. As you can see on top left corner, the navigation links for home and about is displayed. See full detail: http://www.c-sharpcorner.com/UploadFile/dpatra/SilverlightNavigationApplication05232009062853AM/SilverlightNavigationApplication.aspx

RSS Feed Widget in Silverlight

Image
Introduction This is a new widget of my recent posts in c-sharpcorner. This widget is called RSS Feed Widget. The basic functionality of this widget is to display the Links when the RSS Feed is provided. The following figure will describe you everything. Figure 1.1 RSS Feed Widget Steps To begin with we need the following requirements: Silverlight 3 Visual Studio 2008 SP1 Expression Blend 3 Creating a Silverlight Project with or without RIA enabled. Create project in Visual Studio and open the solution in Expression Blend 3. The following figure will guide you for that. See full detail: http://www.c-sharpcorner.com/UploadFile/dpatra/RSSFeedWidget05212009042646AM/RSSFeedWidget.aspx

Using jQuery for AJAX in ASP.NET

Introduction Have an ASP.NET 1.1 site that you want to quickly add some AJAX functionality to? Could you use the new Microsoft AJAX release? Of course, but you could also use any of the popular JavaScript libraries available and do it yourself just as easily. In some cases, you may not want to use the new Microsoft AJAX. Luckily, there are plenty of other good (and easy) alternatives! This article will demonstrate how to use a popular JavaScript library (jQuery) to add AJAX capabilities to your application with a minimal amount of code. Background So, why wouldn't you upgrade to ASP.NET 2.0 and just use the new AJAX functionality provided by Microsoft? Well, if your site is deployed and working – you may not want (or be able to) upgrade to ASP.NET 2.0 as quickly as you would like to. You could, of course, use the new Microsoft AJAX functionality in your ASP.NET 1.1 application (as noted in this article ), but just in case you don't want to – this article offers a

Using jQuery to directly call ASP.NET AJAX page methods

When it comes to lightweight client-side communication, I’ve noticed that many of you prefer ASP.NET AJAX’s page methods to full ASMX web services. In fact, page methods came up in the very first comment on my article about using jQuery to consume ASMX web services . Given their popularity, I’d like to give them their due attention. As a result of Justin ’s question in those comments, I discovered that you can call page methods via jQuery . In fact, it turns out that you can even do it without involving the ScriptManager at all. In this post, I will clarify exactly what is and isn’t necessary in order to use page methods. Then, I’ll show you how to use jQuery to call a page method without using the ScriptManager . Creating a page method for testing purposes. Writing a page method is easy. They must be declared as static , and they must be decorated with the [WebMethod] attribute. Beyond that, ASP.NET AJAX takes care of the rest on the server side. This will be o

ASP.NET, jQuery and Intellisense

Visual Studio and jQuery Microsoft has partnered with jQuery and because of that, Visual Studio will now include jQuery; if you have downloaded the latest version of ASP.NET MVC, you should find that jQuery was included although it is version 1.2.6 (the current version is 1.3.2). jQuery is a JavaScript framework that is comprehensive in its current form and constantly improving; the jQuery community has developed a number of terrific plug-ins that continually make the kit more attractive, valuable, and useful; it you have not tried it out, it is definitely worth looking into. As far as the plug-ins go, the tablesorter and tablesorter pager really make the whole thing worthwhile if you are working with MVC at all; I think it is a far better solution than using the paged list option demonstrated in the latest "Nerd Dinner" application made available by Guthrie, Hanselman, Haack, et al., if for no other reason than it handles both paging and sorting rather than j

Auto Refresh data on page using AJAX

Image
Hi this is my first article on C# corner. I have some good topics in my mind, stay tuned. In this article, I am going to explain how we can auto refresh data on an ASP.NET page after a certain interval using AJAX UpdatePanel and other controls. I am using some Ajax controls and using SQL server database and Data Grid control. Database name is north wind. In this application my interval time for refresh data is 30 second. You can change your time by times interval property. Here is a snapshot:  This code for bind data: Public Sub BindData() con = New SqlConnection( "Initial Catalog=Northwind; Data Source=localhost; Uid=sa; pwd=;" ) cmd.CommandText = "select * from Employees " cmd.Connection = con con.Open() da = New SqlDataAdapter(cmd) da.Fill(ds) cmd.ExecuteNonQuery() GridData.DataSource = ds GridData.DataBind() End Sub You can check your current time on page load. Write this code: MyLabel.Te

Search and selection of data using LINQ

Image
In our programming practice we often face a situation, when we should search and select some data according to parameters, which are defined by users. In this case we, as usual, have some form (screen) with special fields, which allow to a user to select parameters for his own choice. For example, we have some form to view data of a table (named Persons) with fields ID, FirstName, LastName, (some other fields), HomeSite. Our users want to find in one case only person with HomeSite London1 and FirstName Mike; in another case a user want to see all persons, that there are in our table. In this article I will show how you can use LINQ for such situations. For simplicity we will consider a little project with only two tables: C_Person and NC_Site (fig.1) : Fig. 1. In our solution (named So) there are three projects: project with all our web forms etc. (So), project for our business logic (SoBL, output type class library) and project for data access layers (SoDal, output type c

Geographical Information By IP Address

There are a lot services by which we can find Visitor Geographical information like country, region, city, latitude, longitude, ZIP code, time zone etc from I.P Addresses. Here in this article I use http://iplocationtools.com/ free IP Geolocation API that returns geographical data in three formats: XML, JSON and CSV This is the aspx code: See full detail: http://www.c-sharpcorner.com/UploadFile/rahul4_saxena/GeographicalInformationByIPAddress06022009025825AM/GeographicalInformationByIPAddress.aspx

Windows Vista Security, Review of Data Execution Prevention

Windows Vista introduces a range of new technologies that make the most secure desktop version of Windows to date. The following article provides an objective analysis of one of these improvements. Our goal is to help people better understand the true security climate that awaits them with Windows Vista, in this case with DEP (Data Execution Prevention). Security technologies in Windows Vista With the introduction of Windows Vista, Microsoft has leveraged a number of security technologies in order to mitigate several classes of attack that have historically plagued the Windows operating system. These technologies are numerous, and are best described visually in the following figure: See full detail: http://www.c-sharpcorner.com/UploadFile/edinson_2109/WindowsVistaSecurity-Review-of-DEP05302009191115PM/WindowsVistaSecurity-Review-of-DEP.aspx

Partial Classes in C#

Partial Class In this article I will explain what is a partial class? What are the benefits of using partial classes and how to implement partial classes in your C# applications. Partial class is a new feature added to C# 2.0 and Visual Studio 2005. It is supported in .NET Framework 2.0. If you are working with .NET 1.0 or 1.1, partial classes may not work. It is possible to split the definition of a class or a struct, or an interface over two or more source files. Each source file contains a section of the class definition, and all parts are combined when the application is compiled. When working on large projects, spreading a class over separate files allows multiple programmers to work on it simultaneously. When working with automatically generated source, code can be added to the class without having to recreate the source file. Visual Studio uses this approach when creating Windows Forms, Web Service wrapper code, and so on. You can create code

Dynamic and Static Array Declarations

There are 2 methods commonly used for declaring arrays. While both have their place and usage, most programmers prefer the dynamic array that is declared at run-time to provide the most flexibility. The static array is great if you have a set structure that will never change. For instance, an array that holds the days of the week, months in the year, or even the colors in a rainbow. These won't change and they won't be data driven so in this case, a static array will be best. Static Arrays Arrays can be declared in many ways. These first examples demonstrate arrays that are created at "design time" – (programmer sets the value(s) and length). This array is "hard coded". Hard coded means that the values and length of the array are established at the time the array is declared and isn't based on user input or stored data. It won't vary while the program is running. Notice that there is more than one way to declare this type of arrays

Using PostgreSQL from Microsoft.NET

Introduction PostgreSQL is one of the most important relational database systems in the open source world. It is released under a BSD style license. I've seen a few documents talking about the development of .NET application with PostgreSQL as the back-end server. That's why I'm writing this article to illustrate how you can access to the PostgreSQL database system using C#. Getting started with the solution For this solution, we're going to use the PostgreSQL database system which can be downloaded from http://www.postgresql.org/ . You can also find a good documentation in this site. For the creation of the database and its underlying schema, we're going to use pgAdmin III. In order to access to the PostgreSQL database system from Microsoft.NET, we're going to use NpgSQL2 driver for ADO.NET which can be downloaded from http://npgsql.projects.postgresql.org/ . When you unzip the npgsql archive, you can find the driver in the Npgsql.dll library ins

MVC Declarative Binding

One of the things that makes the bar to implement any "MVC-ish" pattern high is the tremendous amount of plumbing required just to get started in order for the different entities to communicate state changes. This article introduces a utility library that can be used to declaratively bind the model and view encapsulating all the wiring required and making implementation much easier. Here's how to consume the library: The idea is to declaratively bind property and collection change events. I have created two attributes for this: BoundToPropertyAttribute and BoundToCollectionAttribute . We can either define these on an interface the view will implement (which is the usage I prefer) or we can declare the attributes on the concrete view. public interface IPersonView { [ BoundToProperty ( typeof ( Person ), "Name" )] String Name { get ; set ; } [ BoundToCollection ( BoundCollectionChangedMethod .AddItems)] void FriendsAdded( IEn

An Introduction to Windows Communication Foundation (WCF)

Image
WCF Overview 1.0 What Is WCF? WCF stands for Windows Communication Foundations. WCF combines the functionality from ASP.NET Web Services, .NET Remoting, Message Queuing and Enterprise Services. WCF provides the following features, Hosting For Component & Services WCF Service can be hosted in ASP.NET Runtime, a Windows Service, a COM+ Component or just a Windows form application for peer-to-peer computing. Declarative Behavior Similar to ASP.NET Web Services, attributes can be used for WCF Services e.g. ServiceContract(), OperationContract, DataContract and DataMember Communication Channels Similar to .NET Remoting WCF Services are flexible in changing the channels. WCF offers multiple channels to communicate using HTTP, TCP or an IPC channel. Security Extensibility 2.0 Understanding WCF- These days we are creating the software/application which should be capable of communication with other applications as well. Communication with other application simply mean

Tuning Up SQL Server 2005 Databases

It's a familiar problem for most developers. The application is just about finished, the near-final bits are rolled out to the test servers...and things aren't quite fast enough to suit everyone. As you scramble around looking for places to squeeze out another few percentage points of performance, the database looks like a likely suspect. The problem is that no one on the team is a real expert in the esoterica of SQL Server indexing and physical architecture design. So what can you do to make sure you've got things set up for optimal database performance? Fortunately, SQL Server 2005 comes with a built-in answer to this problem: the Database Engine Tuning Advisor. Combining a simple user interface with a deep knowledge of SQL Server, this utility can help you tune your databases for peak performance. In this article I'll walk you through using the Tuning Advisor and show you what it can do for you. You Can't Tune in a Vacuum The first thing you need to understand wh

Architecture FAQ for Localization and Globalization: Part I

Image
Introduction When we see around, architectures mainly discuss about loose coupling , scalability , performance etc etc. Many architecture forget one of the important aspects in software is making application globalized. Depending on project some application would not really want to have multi-language based websites , but I am sure many will. So in this article we will go through a series of FAQ which will give you a quick start on making application multi-language based. What is Unicode & Why was it introduced? In order to understand the concept of Unicode we need to move little back and understand ANSI code. ASCII (ask key) stands for American Standard Code for Information Interchange. In ASCII format, every character is represented by one byte (i.e. 8 bits). So in short we can have 256 characters (2^8). Before UNICODE came in to picture programmers used code page to represent characters in different languages. Code page is a different interpretation of ASCII set. C

.NET FTP Component for C#, VB.NET, and ASP.NET.

How to use FTP in .net application? We can use third pary componet for FTP in .net application like Chilkat See detail: http://www.example-code.com/csharp/ftp_upload.asp See detail: http://www.chilkatsoft.com/ftp-2-dotnet.asp

Check Internet Connection in .net

How to check internet connection in .net application? For checking Internet connection in .NET application, we can use GetIsNetworkAvailable method defined in the System.Net.Network-Information namespace. But it returns a Boolean value that denotes whether any network connection is available and does not say about Internet connectivity. To make sure we also have Internet access, the reliable method is to attempt to ping a host using System.Net.NetworkInformation; public bool IsInternet_Connected() { string hostName = " http://www.google.com " ; bool bl_result = false ; Ping p = new Ping (); try { PingReply ping_reply = p.Send(hostName, 3000); if (ping_reply.Status == IPStatus .Success) return true ; } catch (Exception ex) { throw ex; } return bl_result; } We can also use a simple API function InternetGetConnectedState. This function takes two arguments: The first one is an integer used with out keyword, which means that after calling the function, the var