Saturday, December 8, 2007

ajax: a new approach to web applications

by Jesse James Garrett

February 18, 2005

If anything about current interaction design can be called “glamorous,” it’s creating Web applications. After all, when was the last time you heard someone rave about the interaction design of a product that wasn’t on the Web? (Okay, besides the iPod.) All the cool, innovative new projects are online.

Despite this, Web interaction designers can’t help but feel a little envious of our colleagues who create desktop software. Desktop applications have a richness and responsiveness that has seemed out of reach on the Web. The same simplicity that enabled the Web’s rapid proliferation also creates a gap between the experiences we can provide and the experiences users can get from a desktop application.

That gap is closing. Take a look at Google Suggest. Watch the way the suggested terms update as you type, almost instantly. Now look at Google Maps. Zoom in. Use your cursor to grab the map and scroll around a bit. Again, everything happens almost instantly, with no waiting for pages to reload.

Google Suggest and Google Maps are two examples of a new approach to web applications that we at Adaptive Path have been calling Ajax. The name is shorthand for Asynchronous JavaScript + XML, and it represents a fundamental shift in what’s possible on the Web.

Defining Ajax

Ajax isn’t a technology. It’s really several technologies, each flourishing in its own right, coming together in powerful new ways. Ajax incorporates:

The classic web application model works like this: Most user actions in the interface trigger an HTTP request back to a web server. The server does some processing — retrieving data, crunching numbers, talking to various legacy systems — and then returns an HTML page to the client. It’s a model adapted from the Web’s original use as a hypertext medium, but as fans of The Elements of User Experience know, what makes the Web good for hypertext doesn’t necessarily make it good for software applications.

Ajax Overview 1

Figure 1: The traditional model for web applications (left) compared to the Ajax model (right).

This approach makes a lot of technical sense, but it doesn’t make for a great user experience. While the server is doing its thing, what’s the user doing? That’s right, waiting. And at every step in a task, the user waits some more.

Obviously, if we were designing the Web from scratch for applications, we wouldn’t make users wait around. Once an interface is loaded, why should the user interaction come to a halt every time the application needs something from the server? In fact, why should the user see the application go to the server at all?

How Ajax is Different

An Ajax application eliminates the start-stop-start-stop nature of interaction on the Web by introducing an intermediary — an Ajax engine — between the user and the server. It seems like adding a layer to the application would make it less responsive, but the opposite is true.

Instead of loading a webpage, at the start of the session, the browser loads an Ajax engine — written in JavaScript and usually tucked away in a hidden frame. This engine is responsible for both rendering the interface the user sees and communicating with the server on the user’s behalf. The Ajax engine allows the user’s interaction with the application to happen asynchronously — independent of communication with the server. So the user is never staring at a blank browser window and an hourglass icon, waiting around for the server to do something.

Ajax Overview 2

Figure 2: The synchronous interaction pattern of a traditional web application (top) compared with the asynchronous pattern of an Ajax application (bottom).

Every user action that normally would generate an HTTP request takes the form of a JavaScript call to the Ajax engine instead. Any response to a user action that doesn’t require a trip back to the server — such as simple data validation, editing data in memory, and even some navigation — the engine handles on its own. If the engine needs something from the server in order to respond — if it’s submitting data for processing, loading additional interface code, or retrieving new data — the engine makes those requests asynchronously, usually using XML, without stalling a user’s interaction with the application.

Who’s Using Ajax

Google is making a huge investment in developing the Ajax approach. All of the major products Google has introduced over the last year — Orkut, Gmail, the latest beta version of Google Groups, Google Suggest, and Google Maps — are Ajax applications. (For more on the technical nuts and bolts of these Ajax implementations, check out these excellent analyses of Gmail, Google Suggest, and Google Maps.) Others are following suit: many of the features that people love in Flickr depend on Ajax, and Amazon’s A9.com search engine applies similar techniques.

These projects demonstrate that Ajax is not only technically sound, but also practical for real-world applications. This isn’t another technology that only works in a laboratory. And Ajax applications can be any size, from the very simple, single-function Google Suggest to the very complex and sophisticated Google Maps.

At Adaptive Path, we’ve been doing our own work with Ajax over the last several months, and we’re realizing we’ve only scratched the surface of the rich interaction and responsiveness that Ajax applications can provide. Ajax is an important development for Web applications, and its importance is only going to grow. And because there are so many developers out there who already know how to use these technologies, we expect to see many more organizations following Google’s lead in reaping the competitive advantage Ajax provides.

Moving Forward

The biggest challenges in creating Ajax applications are not technical. The core Ajax technologies are mature, stable, and well understood. Instead, the challenges are for the designers of these applications: to forget what we think we know about the limitations of the Web, and begin to imagine a wider, richer range of possibilities.

It’s going to be fun.


Ajax Q&A

March 13, 2005: Since we first published Jesse’s essay, we’ve received an enormous amount of correspondence from readers with questions about Ajax. In this Q&A, Jesse responds to some of the most common queries.

Q. Did Adaptive Path invent Ajax? Did Google? Did Adaptive Path help build Google’s Ajax applications?

A. Neither Adaptive Path nor Google invented Ajax. Google’s recent products are simply the highest-profile examples of Ajax applications. Adaptive Path was not involved in the development of Google’s Ajax applications, but we have been doing Ajax work for some of our other clients.

Q. Is Adaptive Path selling Ajax components or trademarking the name? Where can I download it?

A. Ajax isn’t something you can download. It’s an approach — a way of thinking about the architecture of web applications using certain technologies. Neither the Ajax name nor the approach are proprietary to Adaptive Path.

Q. Is Ajax just another name for XMLHttpRequest?

A. No. XMLHttpRequest is only part of the Ajax equation. XMLHttpRequest is the technical component that makes the asynchronous server communication possible; Ajax is our name for the overall approach described in the article, which relies not only on XMLHttpRequest, but on CSS, DOM, and other technologies.

Q. Why did you feel the need to give this a name?

A. I needed something shorter than “Asynchronous JavaScript+CSS+DOM+XMLHttpRequest” to use when discussing this approach with clients.

Q. Techniques for asynchronous server communication have been around for years. What makes Ajax a “new” approach?

A. What’s new is the prominent use of these techniques in real-world applications to change the fundamental interaction model of the Web. Ajax is taking hold now because these technologies and the industry’s understanding of how to deploy them most effectively have taken time to develop.

Q. Is Ajax a technology platform or is it an architectural style?

A. It’s both. Ajax is a set of technologies being used together in a particular way.

Q. What kinds of applications is Ajax best suited for?

A. We don’t know yet. Because this is a relatively new approach, our understanding of where Ajax can best be applied is still in its infancy. Sometimes the traditional web application model is the most appropriate solution to a problem.

Q. Does this mean Adaptive Path is anti-Flash?

A. Not at all. Macromedia is an Adaptive Path client, and we’ve long been supporters of Flash technology. As Ajax matures, we expect that sometimes Ajax will be the better solution to a particular problem, and sometimes Flash will be the better solution. We’re also interested in exploring ways the technologies can be mixed (as in the case of Flickr, which uses both).

Q. Does Ajax have significant accessibility or browser compatibility limitations? Do Ajax applications break the back button? Is Ajax compatible with REST? Are there security considerations with Ajax development? Can Ajax applications be made to work for users who have JavaScript turned off?

A. The answer to all of these questions is “maybe”. Many developers are already working on ways to address these concerns. We think there’s more work to be done to determine all the limitations of Ajax, and we expect the Ajax development community to uncover more issues like these along the way.

Q. Some of the Google examples you cite don’t use XML at all. Do I have to use XML and/or XSLT in an Ajax application?

A. No. XML is the most fully-developed means of getting data in and out of an Ajax client, but there’s no reason you couldn’t accomplish the same effects using a technology like JavaScript Object Notation or any similar means of structuring data for interchange.

Q. Are Ajax applications easier to develop than traditional web applications?

A. Not necessarily. Ajax applications inevitably involve running complex JavaScript code on the client. Making that complex code efficient and bug-free is not a task to be taken lightly, and better development tools and frameworks will be needed to help us meet that challenge.

Q. Do Ajax applications always deliver a better experience than traditional web applications?

A. Not necessarily. Ajax gives interaction designers more flexibility. However, the more power we have, the more caution we must use in exercising it. We must be careful to use Ajax to enhance the user experience of our applications, not degrade it.

Jesse James Garrett is President and a founder of Adaptive Path. He is the author of the widely-referenced book The Elements of User Experience. Jesse’s other essays include The Nine Pillars of Successful Web Teams and Six Design Lessons From the Apple Store.

To get essays like this one delivered directly to your inbox, subscribe to our email newsletter. For more, check out our blog.

AJAX DataGrid: An ASP.NET User Control

AJAX DataGrid: An ASP.NET User Control:

Introduction:

This DataGrid is a Client Side Control. It is created by JavaScript and uses Ajax.net technology to communicate with ASP.NET code behind, from there, using ADO.NET to access the database and update the database with dataset.

This control has all the features that a DataGrid should have and all the functions work automatically without writing any code after you setup the connection string and table names.

The datagrid support:

  1. Pages.
  2. Sort.
  3. Master - Detail (the detail part also support page and sort)
  4. Customized row color based on the Column condition.
  5. Edit.
  6. Scroll bar without head scroll when no page supported.
  7. Support controls (Image, TextBox, Hyper link, DropdownBox, CheckBox).
  8. Auto split head name.
  9. Automatic validate textbox for Decimal, email and number.

The datagrid can be switched between different modes by right click on the screen to open a popup screen:

The Datagrid with Page, Master-Detail and Edit function

The Datagrid with custom controls and scrollbar with static head

Performance:

The grid is created by javascript on demand and JavaScript is not a compiled language. It is slower than render xtml code directly to the page. If the datagrid contains more than 200 records it is better to use the page mode. Otherwise the performance will slowdown a lot.

The CSS (Cascading Style Sheets) is used to configure the look of the control, so the user can make the change very easily.

Usage:

The user control includes five parts:

  1. User control .ascx file.
  2. JavaScript file.
  3. Database access file.
  4. CSS file.
  5. AJAX.NET dll.

First, Add reference to ajax.dll.

Copy the UserControl directory to your project and add the user control to your ASP.Net page: (see the project in the source code)

Working with DataGrid Using AJAX: ASP Alliance

Working with DataGrid Using AJAX: ASP Alliance: "Introduction Usually a DataGrid filling or update requires a postback to the server, but using AJAX we can fill the DataGrid contents without a form submit (refresh). In this article, you will learn how to achieve this functionality with the help of a DropDownList control through a sample application. Here we use a DropDownList which is filled with city values; upon changing the DropDownList value, we get the DataGrid filled with the data of authors from the city by using AJAX. This article will be useful for the people who have some basic knowledge about AJAX and who want to enrich that. Since we are aware of basic AJAX functionality, we are moving a step further with this DataGrid example. I will mainly explain about how we send the request from the client, how it gets processed, and how the client script runs to display the data in the Data"

Friday, December 7, 2007

accounting software using vb visual basic asp .net sql server

Database Programming using Visual Basic 2005, C# 2005 & SQL Server 2005

(Includes accounting software source code and Covers Client Server Three Tier architecture)

One

Book cover image of Database Programming using VB, C#. and SQL Server


ISBN: 81-901331-5-2
Price: $19.90/-
Weight: 2.4 Pounds
Pages: 562


Worldwide shipping.
Choose the low cost 7 day
Air Mail (REGISTERED)
or 3 days Courier Service.

We Accept Paypal Payments




about vkinfotek
contents of the Book database programming using visual basic 2005, c# 2005 and sql server

CodeProject: Multi-select ASP.NET datagrid. Free source code and programming articles

CodeProject: Multi-select ASP.NET datagrid. Free source code and programming articles: "Multi-select ASP.NET datagrid By Prashant Nayak (.Net Lover) How to extend ASP.NET datagrid for multi-selection of data rows. C#, VB, JScriptWin95Win98WinMEWin2KWinXPWin2003.NET 1.0.NET 1.1, ASP.NET, VS.NET2002, VS.NET2003, Dev Posted: 12 Sep 2003 Updated: 8 Mar 2004 Views: 378,082 Announcements VS 2008 Visual Studio 2008 competition. $25,000 in prizes Office 2007 Office 2007 comp. Win free travel and passes Comp Monthly Competition Chapters Desktop Development Button Controls Clipboard Combo & List Boxes Dialogs and Windows Desktop Gadgets Document / View Edit Controls Files and Folders Grid & Data Controls Hardware & System List Controls Menus Miscellaneous Printing Progress Controls Selection Controls Shell and IE programming Smart Client Splitter Windows Static & Panel Controls Status Bar Tabs & Property Pages Toolbars & Docking windows Tree Controls Web Development AJAX and Atlas Applications & Tools ASP ASP.NET ASP.NET Controls ATL Server Caching Charts, Graphs and Images Client side scripting Custom Controls HTML / CSS Internet / Network ISAPI Server Management Session State Silverlight Trace and Logs User Controls Validation View State WAP / WML Web Security W"

Microsoft ASP.NET QuickStarts Tutorial

DataGrid

These samples illustrate using the DataGrid control. These examples use sample data rather than data from a real database. Please see the Server-Side Data Access section for examples of DataGrid bound to live data.



Working With DataGrid

The DataGrid control displays tabular data and optionally supports selecting, sorting, paging, and editing the data. By default, DataGrid generates a BoundColumn for each field in the data source (AutoGenerateColumns=true). Each field in the data is rendered in a separate column, in the order it occurs in the data. Field names appear in the grid's column headers, and values are rendered in text labels. A default format is applied to non-string values.

The following sample illustrates using a simple DataGrid control.


VB DataGrid1.aspx

[Run Sample] | [View Source]
LateBreaking Samples:
  • J#

  • Defining Columns in DataGrid

    You can control the order, behavior, and rendering of individual columns by directly manipulating the grid's Columns collection. The standard column type -- BoundColumn -- renders the values in text labels. The grid also supports other column types that render differently. Any of the column types can be used together with the Columns collection of a DataGrid.

    Note that you can use explicitly-declared columns together with auto-generated columns (AutoGenerateColumns=true). When used together, the explicitly-declared columns in the Columns collection are rendered first, and then the auto-generated columns are rendered. The auto-generated columns are not added to the Columns collection.

    Column Name Description
    BoundColumn Lets you control the order and rendering of the columns.
    HyperLinkColumn Presents the bound data in HyperLink controls.
    ButtonColumn Bubbles a user command from within a row to an event handler on the grid.
    TemplateColumn Lets you control which controls are rendered in the column.
    EditCommandColumn Displays Edit, Update, and Cancel links in response to changes in the DataGrid control's EditItemIndex property.

    By explicitly creating a BoundColumn in the grid's Columns collection, you can control the order and rendering of each column. The following example shows how to use BoundColumn.


    VB DataGrid2.aspx

    [Run Sample] | [View Source]
    LateBreaking Samples:
  • J#
  • A HyperLinkColumn presents the bound data in HyperLink controls. This is typically used to navigate from an item in the grid to a Details view on another page. In the following example, the value IntegerValue data field is passed as an argument in the URL to another page, and the StringValue data field is used as the display text of the hyperlink.


    VB DataGrid3.aspx

    [Run Sample] | [View Source]
    LateBreaking Samples:
  • J#
  • A ButtonColumn is used to bubble a user command from within a row to an event handler on the grid. In the following example, the "Add To Cart" and "Remove From Cart" commands cause the item from the row where the button was clicked to be added or removed from a simple shopping cart.


    VB DataGrid4.aspx

    [Run Sample] | [View Source]
    LateBreaking Samples:
  • J#
  • With a TemplateColumn, you completely control which controls are rendered in the column, and which data fields are bound to the controls. The following example includes two TemplateColumn objects. The first column renders two LinkButton controls. These bubble commands to the grid's ItemCommand, just as a ButtonColumn does. The last column binds the true/false value to a read-only CheckBox.


    VB DataGrid5.aspx

    [Run Sample] | [View Source]
    LateBreaking Samples:
  • J#
  • The EditCommandColumn is a special column type that supports in-place editing of the data in one row in the grid. EditCommandColumn interacts with another property of the grid: EditItemIndex. By default the value of EditItemIndex is -1, meaning none of the rows (items) in the grid is being edited. If EditItemIndex is -1, an "edit" button is displayed in the EditCommandColumn for each of the rows in the grid.

    When the "edit" button is clicked, the grid's EditCommand event is thrown. It's up to you to handle this event in your code. The typical logic sets EditItemIndex to the selected row, and then rebinds the data to the grid.

    When EditItemIndex is set to a particular row, the EditCommandColumn displays "update" and "cancel" buttons for that row ("edit" is still displayed for the other rows). These buttons cause the UpdateCommand and CancelCommand event to be thrown, respectively. The following sample demonstrates this functionality.


    VB DataGrid6.aspx

    [Run Sample] | [View Source]
    LateBreaking Samples:
  • J#

  • Editing Data in DataGrid

    In the previous example, the EditCommandColumn was used to support in-place editing of a single row of data. When you use EditItemIndex, the grid automatically inserts the values to be edited into TextBox and CheckBox controls.

    By using TemplateColumn objects for the fields you want to edit, you can precisely control how the data is edited. In the following example, the Quantity and Gift Wrap fields are editable in all rows. When the "Update Totals" button is clicked, the grid's Items collection is traversed to extract the current values for these fields, and the data source is updated.


    VB DataGrid13.aspx

    [Run Sample] | [View Source]
    LateBreaking Samples:
  • J#

  • Hiding Columns in DataGrid

    Each column in the grid has a Visible property. Setting Visible to false hides a column.


    VB DataGrid7.aspx

    [Run Sample] | [View Source]
    LateBreaking Samples:
  • J#

  • Sorting Columns in DataGrid

    Data in a grid is commonly sorted by clicking the header of the column you wish to sort. You can enable sorting in DataGrid by setting AllowSorting to true. When enabled, the grid renders LinkButton controls in the header for each column. When the button is clicked, the grid's SortCommand event is thrown. It's up to you to handle this event in your code. Because DataGrid always displays the data in the same order it occurs in the data source, the typical logic sorts the data source, and then rebinds the data to the grid.

    The following example shows how to implement simple sorting in DataGrid.


    VB DataGrid8.aspx

    [Run Sample] | [View Source]
    LateBreaking Samples:
  • J#
  • You can customize the grid's sorting behavior by creating the Columns collection and manipulating the SortExpression for each column. (For auto-generated columns, the SortExpression is the same as the data field.) Omitting SortExpression on a column disables sorting by that column.

    You can also create an Outlook-style sort button by using a TemplateColumn. Note that the button must also specify the "sort" CommandName. Additionally, it must pass the field by which to sort as a CommandArgument, as shown in the following sample.


    VB DataGrid9.aspx

    [Run Sample] | [View Source]
    LateBreaking Samples:
  • J#

  • Paging in DataGrid

    The DataGrid provides the means to display a group of records from the data source (for example, the first 10), and then navigate to the "page" containing the next 10 records, and so on through the data.

    You enable paging in DataGrid by setting AllowPaging to true. When enabled, the grid will display page navigation buttons either as "next/previous" buttons or as numeric buttons. When a page navigation button is clicked, the PageIndexChanged event is thrown. It's up to you to handle this event in your code. The most basic logic assigns the CurrentPageIndex to the event argument's NewPageIndex property and then rebinds the data source, as shown in the following example.


    VB DataGrid10.aspx

    [Run Sample] | [View Source]
    LateBreaking Samples:
  • J#
  • The DataGrid has a built-in page navigation control, called the "pager," which displays either as "next/previous" buttons or as a set of numeric page buttons. You can hide the built-in pager user interface and supply your own paging UI.

    To change the page, you must set the CurrentPageIndex to the desired page (base 0), and rebind the data source to the grid.


    VB DataGrid11.aspx

    [Run Sample] | [View Source]
    LateBreaking Samples:
  • J#
  • For very large data models, it is expensive to load the entire data source each time the grid is paged. A common alternative is to retrieve the data in page-size chunks, rather than retrieving all of the data and then stepping into the current row.

    The DataGrid supports chunking through the AllowCustomPaging and VirtualItemCount properties. If AllowCustomPaging is true, the DataGrid does not calculate a starting display position in the data model based on CurrentPageIndex. Instead, DataGrid displays all of the data in the data model, while its pager reports the current position as page CurrentPageIndex of (VirtualItemCount+PageSize-1)/PageSize. The following example demonstrates this functionality.


    VB DataGrid12.aspx

    [Run Sample] | [View Source]
    LateBreaking Samples:
  • J#
  • ASP.NET.4GuysFromRolla.com: An Extensive Examination of the DataGrid Web Control: Part 1

    Introduction
    One of the most common tasks in classic ASP was retrieving tabular information from a database and displaying it in an HTML table. With classic ASP this would require many lines of intermixed HTML and code; the following pseudocode shows what the code would commonly look like:

    Create Database Connection
    Populate a recordset based on some SQL query
    Output the HTML table header ()
    Loop through the recordset
    Emit the HTML for a table row
    ...
    Emit the HTML table footer (
    )

    If you're an ASP developer chances are you've written code like above more times than you'd care to admit! One of the advantages of ASP.NET is that it contains a number of Web controls. These Web controls, which emit HTML, provide a programmatic interface, allowing developers to separate code and content and treat these HTML emitting entities as objects in their code. That is, if we wanted to display some HTML content using ASP.NET we'd do the following:

    Code Library of e-July

    Code Library of e-July

    Raja N: November 2007

    Raja N: November 2007

    Media Convert - free and on line - convert and split sound, ringtones, images, docs - MP3 WMV 3GP AMR FLV SWF AMV MOV WMA AVI MPG MP4 DivX MPEG4 iPOD

    Media Convert - free and on line - convert and split sound, ringtones, images, docs -

    Media-Convert is 100% free. No software is needed, and you don't have to register. You only need your favorite Internet browser. Your files are ready 7/7 days 24/24 hours.

    How to convert a file ?

    To convert a file located on your computer : Check File mode, click Browse and choose the file, select input format (if autodetection fails) and output format, submit the form.

    How to display serial no in datagrid

    How to display serial no in datagrid ????
    In my page i have used datagrid for displaying data.On datagrid i have one field named serial no. with out database help how to display serial no.


    I have used the following for dispalying serial no

    <%#Container.ItemIndex+1 %>

    but when on paging it not display correctly.

    Answer

    Int row;

    if (e.Item.ItemType == ListItem.ListItemType.Item || e.Item.ItemType == ListItem.ListItemType.AlternateItem)
    {

    row = e.Item.ItemIndex+ (DataGrid1.PageSize * DataGrid1.CurrentPageIndex);

    ((Label)e.Item.FindControl("lblSrNo")).Text=row.ToString();


    }

    Sending Email with ASP.NET

    Sending Email with ASP.NET

    Written by: Christoph Wille
    Translated by: Bernhard Spuida
    First published: 9/18/2000
    Viewed 396868 times. 106 ratings, avg. grade 3.08

    Something found on every web page today is an email form of some sort. In all probability this will not change anytime soon, therefore I will demonstrate today how to send email via ASP.NET: from plain to HTML mail and attachments.

    The use of the source code in this article requires an installation of Microsoft's .NET Framework SDK on a Web server. I also assume a certain familiarity of the reader with the C# programming language.

    The quickest way

    There always is a way that can be classified under the heading 'Quick and Dirty'. And I again want to begin with this way because we can test the server configuration quite easily without having to take any side effects into consideration (SimpleMail.aspx).

    &lt% @Page Language="C#" %&gt
    &lt% @Import Namespace="System.Web.Mail" %&gt

    string strTo = "christophw@sleeper.Dev.AlfaSierraPapa.Com";
    string strFrom = "webmaster@aspheute.com";
    string strSubject = "Hi Chris";

    SmtpMail.Send(strFrom, strTo, strSubject,
    "A real nice body text here");

    Response.Write("Email was queued to disk");
    &gt

    If everything went well, the result looks like the following screenshot:

    What actually happens in the script? The complete email support resides in the System.Web.Mail namespace. In this namespace we find the class SmtpMail, whose static Send method can accept four parameters:

    SmtpMail.Send(From, To, Subject, BodyText);

    As I said, it is very simple, but it has one thing in common with the more functional email sending options: the SMTP Server must be the locally installed SMTP Service of the IIS - no other can be used. In this respect the email support of ASP.NET is identical with the CDONTS of ASP 3.0.

    Sending HTML Email

    But now we leave this all too simple method behind and look at a very functional object: the MailMessage class. This class 'encapsulates' everything one can wish for in an email - the following example demonstrates the use with a short HTML email (SimpleMailMessage.aspx).

    &lt% @Page Language="C#" %&gt   
    &lt% @Import Namespace="System.Web.Mail" %&gt
    &lt%
    MailMessage msgMail = new MailMessage();

    msgMail.To = "christophw@sleeper.Dev.AlfaSierraPapa.Com";
    msgMail.Cc = "webmaster@sleeper.Dev.AlfaSierraPapa.Com";
    msgMail.From = "webmaster@aspheute.com";
    msgMail.Subject = "Hi Chris, another mail";

    msgMail.BodyFormat = MailFormat.Html;
    string strBody = "Hello World" +
    " ASP.NET";
    msgMail.Body = strBody;

    SmtpMail.Send(msgMail);

    Response.Write("Email was queued to disk");
    %&gt

    The code looks much better now and above all, there are significantly more options than there are in the first Send method. First we set the To, From and Subject properties of the MailMessage then we set the BodyFormat to the value Html out of the MailFormat enumeration. And then we already are set to send a HTML email.

    Worth mentioning is the fact that all overloads of the Send method do not have return values about the success of dispatching the email message. The reason for this is that the emails simply are written into the Pickup folder of the Inetpub directory from where they are read and then sent by the SMTP Service. Failed emails (dispatching errors) also are written into files, this time however in the Badmail folder.

    As an addendum, I want to show a screenshot of the email:

    Sending Attachments

    With certain email components, sending attachments can be a bit of an adventure. With .Net, it is just another easy to use component: MailAttachment. The following code demonstrates how an attachment can be added to the MailMessage (MailAttachment.aspx).

    &lt% @Page Language="C#" %&gt
    &lt% @Import Namespace="System.Web.Mail" %&gt
    &lt%
    MailMessage msgMail = new MailMessage();

    msgMail.To = "christophw@sleeper.Dev.AlfaSierraPapa.Com";
    msgMail.From = "webmaster@aspheute.com";
    msgMail.Subject = "Attachment Test";

    msgMail.BodyFormat = MailFormat.Text;
    msgMail.Body = "Check out the attachment!";
    msgMail.Attachments.Add(new MailAttachment("c:\\temp\\annual-report.pdf"));

    SmtpMail.Send(msgMail);

    Response.Write("Email was queued to disk");
    %gt

    The line

    msgMail.Attachments.Add(new MailAttachment("c:\\temp\\annual-report.pdf"));

    might also be programmed as follows

    MailAttachment maAttach = new MailAttachment("c:\\temp\\annual-report.pdf");
    IList msgAttachments = msgMail.Attachments;
    msgAttachments.Add(maAttach);

    The point I want to make is that the attachments are handled through an IList interface (to be found in the System.Collections namespace) - and this supplies the Add method. This IList interface can also be used to enumerate or delete attachments. An additional remark has to be made about the constructor of MailAttachment: the encoding type can be set (this is probably rarely needed).

    I still owe you a screenshot - this is what the attachment looks like in Outlook Express. Small programming effort, big effect (when something meaningful is sent).

    Source Code for Creating an ASP.NET Visitor Feedback Page

    Source Code for Creating an ASP.NET Visitor Feedback Page
    "Source Code for Creating an ASP.NET Visitor Feedback
    Page Sub btnSendFeedback_Click(sender as Object, e as EventArgs) 'Create an instance of the MailMessage class Dim objMM as New MailMessage() 'Set the properties - send the email to the person who filled out the 'feedback form. objMM.To = 'webmaster@yoursite.com' objMM.From = txtEmail.Text 'If you want to CC this email to someone else, uncomment the line below 'objMM.Cc = 'someone@someaddress.com' 'If you want to BCC this email to someone else, uncomment the line below 'objMM.Bcc = 'someone@someaddress.com'"

    Sending Email from an ASP.NET Web Page

    Introduction
    One of the most commonly asked questions at ASPMessageboard.com is along the lines of, "How do I send an email through an ASP page?" The wide array of email FAQs on ASPFAQs.com is also proof of this being a commonly asked question. In this article, we will look at how to send email from an ASP.NET Web page! (For more information about ASP.NET be sure to check out the ASP.NET Article Index.)



    In order to send an email from an ASP.NET Web page, you need to use the SmtpMail class, found in the System.Web.Mail namespace, which contains a static method Send. (More on this class later in the article!) In any case, the simplest way to send an email is to call this Send method passing in an instance of the MailMessage class. What's the MailMessage class, you ask? It's a class (also in the System.Web.Mail namespace) that represents an email message.

    Creating a MailMessage
    The MailMessage class contains properties very similar to those found in CDONTS (the often-used component to send emails from a classic ASP page). Such properties include: To, From, Cc, Bcc, BodyFormat, Subject, Priority, Body, etc. So, to send an email, we should create an instance of the MailMessage class and set its properties.

    'Create an instance of the MailMessage class
    Dim objMM as New MailMessage()

    'Set the properties
    objMM.To = "someone@someaddress.com"
    objMM.From = "someoneelse@someotheraddress.com"

    'If you want to CC this email to someone else...
    objMM.Cc = "someone2@someaddress.com"

    'If you want to BCC this email to someone else...
    objMM.Bcc = "someoneElse@someaddress.com"

    'Send the email in text format
    objMM.BodyFormat = MailFormat.Text
    '(to send HTML format, change MailFormat.Text to MailFormat.Html)

    'Set the priority - options are High, Low, and Normal
    objMM.Priority = MailPriority.Normal

    'Set the subject
    objMM.Subject = "Hello there!"

    'Set the body - use VbCrLf to insert a carriage return
    objMM.Body = "Hi!" & vbCrLf & vbCrLf & "How are you doing?"

    Note that you will need to import the System.Web.Mail namespace in your ASP.NET Web page in order to be able to utilize the above code as-is: <% @Import Namespace="System.Web.Mail" %>.

    Sending the MailMessage
    Once we have a MailMessage class instance with the correct properties set, sending the actual email is a breeze. We simply need to call the static Send method of the SmtpMail class, passing in the MailMessage class instance:

    'Now, to send the message, use the Send method of the SmtpMail class
    SmtpMail.Send(objMM)

    The SmtpMail class uses the SMTP Service built into Windows 2000 to do the work of actually sending the email message. By using the Send method above, the local SMTP server is used to send the email message. In order to specify a different SMTP mail server to use to send the message, set the SmtpServer property:

    SmtpMail.SmtpServer = emailServerName

    Be careful, though. Since this is a static property, changing this value in one ASP.NET Web page will affect all ASP.NET Web pages using sending emails via the SmtpMail object. That is, if in one ASP.NET Web page you set the SmtpServer property to myMailServer, and then, in another ASP.NET Web page, do not specify the SmtpServer property, intending to use the default SMTP server, myMailServer will be used instead. For that reason, you should probably always specify the SmtpServer property - if you want to use the default SMTP server, simply do:

    SmtpMail.SmtpServer = ""


    Thursday, December 6, 2007

    QuickStarts Source Control Viewer

    QuickStarts Source Control Viewer: " void ValidateBtn_Click(Object Sender, EventArgs E) { if (Page.IsValid == true) { lblOutput.Text = 'Page is Valid!'; } else { lblOutput.Text = 'Some of the required fields are empty'; } } Simple RequiredField Validator Sample "

    411ASP.NET: ASP.NET Code Snippet

    411ASP.NET: ASP.NET Code Snippet: "Validating Date Code Snippet Hits Today: 11 Total: 28715 Updated: 6/22/2002 Reviews: 1 Rating: Read Reviews | Report Error | Add To QuickList A normal query asked is to validate the date in a specific format. The sample code demonstrates to validate a date in a specific given format. Sample Below checks for the date given in mm/dd/yy or mm/dd/yyyy format"

    Design Templates

    Design Templates: "Design Templates Download these professionally designed Starter Kits and XHTML templates to get you started creating compelling, standards-compliant Web pages with ASP.NET 2.0. There are four Starter Kits below. These Starter Kits are complete web site solutions using ASP.NET’s latest controls (tree view control, grid view control, detail view control, login control, site map path controls and more). There are another 5 XHTML templates below. These are individual XHTML strict Web page templates (available each in two different colors) that are accompanied by design philosophy whitepapers that describe each template’s Section 508 conformance, page layout with CSS (page layouts using CSS floats or tables), Web page accessibility best practices and Web standard resources. All nine templates below are easily customizable and extendable to fit your own content."

    Wednesday, December 5, 2007

    hosthg

    hosthg: "javascript errorScott Webb04 December 2007 submitted by Scott Webb The error console in Firefox does a much better job of actually pointing you in the right direction, but this can be better. Below is a list of good tools that will help ease the pain of JavaScript debugging. all the details here Comments Off Dynamic array manipulation javascript arrayUlises Church04 December 2007 submitted by Ulises Church Forum: JavaScript Posted By: vdubjunkie Post Time: 12-04-2007 at 12:56 PM. more here Comments Off"

    how to delete a row in a dataset in C#, VB.NET, ASP.NET

    how to delete a row in a dataset in C#, VB.NET, ASP.NET

    Calendars : A collection of JavaScript Calendar scripts, programs, and applications

    Calendars : A collection of JavaScript Calendar scripts, programs, and applications: "* Top * JavaScript * Scripts and Programs * Calendars Basic Calendar * Visit * Rate * Error Visit Basic Calendar If you need a simple, elegant calendar to display the current days of the month, the current date is highlighted within the Calendar. Basic Calendar is an excellent script for the purpose. Uses CSS to allow easy changing to its appearance, everything from calendar dimensions, colors, down to the font used to highlight the current day. Easily expand script to display multiple months, either all at once or otherwise. You can create simple functions to display the calendar dynamically, such as on demand using a drop down menu. * Details * Cost: Free CodeThatCalendar * Visit * Rate * Error Visit CodeThatCalendar CodeThatCalendar enables you to easily add the date/time picker to your form or page. Both popup and inline calendars are supported. Features include support for current date and week highlighting, localization, CSS support; Ability to setup start year, date; Configurable scrolling feature; Support for various date formats; Ability to configure the Calendar through the CSS styles; Inline calendar support; Un"

    Javascript: Popup Calendar Control - Engineering Computer Network

    Javascript: Popup Calendar Control - Engineering Computer Network: "Javascript: Popup Calendar Control On several occasions when developing web applications it is necessary to have users provide dates as input. There are several ways to have the user input a date in an HTML form: enter as text, select from drop down list, choose from a calendar, etc. ECN has developed a simple Javascript Popup Calendar Control which can be tied to a text field in a form to collect dates from the user. If the javascript is not supported by the users' browser or they have chosen to disable it, dates can still be entered by typing a date into the text field. Example"

    Search Result

    Search Result: "Re: Draw a table in windows form Posted By A.Wegierski on Oct 22, 2004 DataGrid not required datatable to bind at design time. In such cases objects inside datagrid aren't created - are invisible. You can use DesignMode property to add a dummy datatable with datarow(s). True difficulty is in another place: how to add controls into DataGrid. Standard controls are: TextBox and CheckBox column styles. You can try to create - or find - UserControl. how to make my textbox focus in an editable datagrid? Posted By crayon on Oct 21, 2004 there is my code for update command.. Public Sub DataUpdate(ByVal Sender As Object, ByVal E As DataGridCommandEventArgs) If CheckTime(CType(E.Item.FindControl('txtStd'), TextBox).Text) = 'Error' Then Response.Write(msgbox('Invalid Input!!')) setFocus(CType(E.Item.FindControl('txtStd'), TextBox)) Exit Sub End If end sub here is my setfocus functions.. Private Sub setFocus(ByVal ctrl As System.Web.UI.Control) Dim s As String = '' RegisterStartupScript('focus', s) End Sub the setfocus function is working properly when the control is outside the datagrid.. but i cant make it focus in my editable datagrid.. anyone knows what's going wrong?? Re: DataGrid , HeadClick Event Posted By A.Wegierski on Oct 21, 2004 Simply use Click event and check what was clicked using HitTest() method. HitTestInfo object has an error - it's"

    Summary Rows in a DataGrid: A Comparison of Techniques: ASP Alliance

    Summary Rows in a DataGrid: A Comparison of Techniques: ASP Alliance: "Summary Rows in a DataGrid: A Comparison of Techniques page 1 of 1 Published: 20 Sep 2003 Abstract A summary row in a DataGrid is a row that has column totals, averages, or some other type of summary information. A summary row is indispensible for a DataGrid with many numbers. I have used three different summary row techniques with DataGrids and have found each technique has its advantages (and, of course, its disadvantages). In this article, I give examples of each of the techniques and discuss how one technique may be preferable to another in a given situation. In this article, I call these three techniques Rollup, DataTable Loop, and ItemDataBound. by Daniel Olson Feedback Average Rating: This article has not yet been rated. Views (Total / Last 10 Days): 17200/ 156 A summary row in a DataGrid is a row that has column totals, averages, or some other type of summary information. A summary row is indispensible for a DataGrid with many numbers. I have used three different summary row techniques with DataGrids and have found each technique has its advantages (and, of course, its disadvantages). In this article, I give examples of each of the techniques and discuss how one technique may be preferable to another in a given situation. In this article, I call these thr"

    Selecting, Confirming and Deleting Multiple DataGrid items in ASP.NET: ASP Alliance

    Selecting, Confirming and Deleting Multiple DataGrid items in ASP.NET: ASP Alliance: "Selecting, Confirming and Deleting Multiple Data Grid items Always wanted to build an easy solution to select multiple items from an ASP.NET DataGrid and delete them all at once like hotmail does? Well, it is built in just a few simple steps. To start with, I am assuming that you are using an Access database in the backend and know how to populate DataGrid from database in ASP.NET. If not, look at my other article for beginners 'Basics of Displaying Database Items on Web in ASP.NET' that will be published soon. Now, to create a selection checkbox in your data grid, first set up your data grid as you would do it normally by dragging and dropping from toolbox in to your webForm1.aspx page. Then right click on data grid and select property builder. Go to column property tab and add a template column to the list of selected columns keeping it on the top of the list. Set the header text value as Select or whatever you wish. Click OK when you are done. Once you are back on your design page, again right click on data grid and this time you will see another option of edit template column. Click on to edit template column and drag and drop checkbox control into I"

    Creating DataGrid Filter Using Standard Controls: ASP Alliance

    Creating DataGrid Filter Using Standard Controls: ASP Alliance: "Creating DataGrid Filter Using Standard Controls Published: 27 Sep 2006 Abstract In this article Nidal demonstrates how to create a DataGrid filter using TextBox and ComboBox. by Nidal Arabi Feedback Average Rating: This article has not yet been rated. Views (Total / Last 10 Days): 15721/ 293 Article Contents: * Problem * Solution * Downloads * Summary Problem [ Back To Top ] There are multiple cases where you are asked to provide a filter on your DataGrid. For example, you need a filter when using a typed text or even when allowing the user to select from a specified list. In this article I will explain one way of providing the end user with a professional look and performance even if you are dealing with millions of records. For demonstration purposes I will be using the NorthWind database available from Microsoft for download. Take a look a Figure 1 to get a feeling for what we are going to have in the end. Figure 1 To arrive at this point I shall explain in detail every step. Solution [ Back To Top ] To start with you have to create four essentials stored procedures that will help build the data layer of this screen. Note that these stored p"

    Creating DataGrid Filter Using Standard Controls: ASP Alliance

    There are multiple cases where you are asked to provide a filter on your DataGrid. For example, you need a filter when using a typed text or even when allowing the user to select from a specified list.

    In this article I will explain one way of providing the end user with a professional look and performance even if you are dealing with millions of records.

    For demonstration purposes I will be using the NorthWind database available from Microsoft for download.

    Take a look a Figure 1 to get a feeling for what we are going to have in the end.

    Figure 1

     

    To arrive at this point I shall explain in detail every step.

    Solution

    To start with you have to create four essentials stored procedures that will help build the data layer of this screen. Note that these stored procedures can be formulated directly within code; however, it is much more professional to create them using Microsoft SQL Server.

    The code for the four stored procedure is presented below.

    Listing 1

    ALTER PROCEDURE dbo.SelectAllProducts
    AS
    Select Top 50 * From Products
    RETURN @@RowCount

    A Procedure to Select Products By Category Id

    Listing 2

    ALTER PROCEDURE dbo.SelectProductByCategoryId
    (@CategoryId as int)
    AS
    Select * From Products Where CategoryId = @CategoryId
    RETURN @@RowCount

    A Procedure to Select Product By Name

    Listing 3

    ALTER PROCEDURE dbo.SelectProductByName
    (@ProductName as varchar(50))
    AS
    Select * From Products Where ProductName Like '%' + @ProductName + '%'
    RETURN @@RowCount

    A procedure used to populate the category ComboBox

    Listing 4:

    ALTER PROCEDURE dbo.CbxCategories
    AS
    Select CategoryID, CategoryName From Categories
    RETURN @@RowCount

    After having created these four stored procedures, we are able to proceed with the ASP.NET application. Follow the steps given below.

    1. You need to create a new ASP.NET web application, name it DataGridFilter and place it in the default directory.

    2. In webform1 that is open, drag a DataGrid from the toolbox into it.

    3. Give the DataGrid the professional look by applying AutoFormat from the right click menu.

    4. Now, right click and choose property builder for designing our DataGrid.

    5. Go to the column's option and clear the check box of Create Columns automatically at run time.

    6. Add a first bound column. The Header should be Product Id and the field name ProductID.

    7. Add a second bound column. The Header should be Name and the field name ProductName.

    8. Add a third bound column. The Header should be Category ID and the field should be CategoryID.

    9. While still in the property builder, choose the bound column of Name and convert it to a template. Do the same for the Category ID column.

    10. Exit the property builder and start template editing of the Name column.

    11. In the Header property, insert a text box and name it TxtFilterName.

    12. Beside it, insert a button with the following properties: Text= , CommandName=Filter, CommandArgument= TxtFilterName, ToolTip=Filter By Name, Name=BtnFilterName

    13. Move into template editing of the Category ID column and insert a drop down list inside the header part and name it CbxFilterCategoryID.

    14. Beside it, insert a button with the following properties: Text= , CommandName=Filter, CommandArgument= CbxFilterCategoryId, ToolTip=Filter By Category, Name=BtnFilterCategory

    15. By now you should have the physical shape of the webform as listed in Figure 2.

    Figure 2

    Now, we move to the coding part.

    First of all, we have to fill the combo box by all available categories in the database. To do this, we write a fairly simple Visual Basic .NET code presented in the listing below in the page code section.

    A code listing to fill the combo box of category

    Listing 5

    Public Function BindCategoryID()
    Dim ConnStr As String = _
    "Data Source=.; Initial Catalog=Northwind; User ID=sa; Password=pass@word1"
    Dim myConnection As SqlClient.SqlConnection = New SqlClient.SqlConnection(ConnStr)
    Dim myCommand As SqlClient.SqlCommand = New SqlClient.SqlCommand("CbxCategories", myConnection)
    myCommand.CommandType = CommandType.StoredProcedure
    myConnection.Open()
    Return myCommand.ExecuteReader(CommandBehavior.CloseConnection)
    End Function

    To complete the binding we need to add the following line in the drop down list in HTML.

    DataSource="" DataTextField="CategoryName" DataValueField="CategoryID".

    If you run your project, you will have your combo box filled with the categories.

    There are some variables that are going to be used for the whole form, thus defining them at the top of the web form.

    Global Form Variables

    Listing 6

    Dim MySQLConnection As New SqlClient.SqlConnection
    Dim MySQLCommand As New SqlClient.SqlCommand
    Dim MyDataAdapter As New SqlClient.SqlDataAdapter
    Dim MyDataSet As New Data.DataSet

    Next is the fun part. Let us see how to fill data and then apply filters.

    Listing 7

    Private Sub SetupData()
    MySQLConnection.ConnectionString = _
    "Data Source=.; Initial Catalog=Northwind; User ID=sa; Password=pass@word1"
    MySQLConnection.Open()
    MySQLCommand.Connection = MySQLConnection
    MySQLCommand.CommandType = CommandType.StoredProcedure
    MySQLCommand.CommandText = "SelectAllProducts"
    MyDataAdapter.SelectCommand = MySQLCommand
    MyDataAdapter.Fill(MyDataSet, "Products")
    DataGrid1.DataSource = MyDataSet
    DataGrid1.DataMember = "Products"
    MySQLConnection.Close()
    End Sub
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
    Handles MyBase.Load
    If Not Me.IsPostBack Then
    Call SetupData()
    DataGrid1.DataBind()
    End If
    End Sub

    To apply the filter when the user clicks the button next to the filter part, just add the following code.

    Listing 8

    Private Sub DataGrid1_ItemCommand(ByVal Source As Object, _
    ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) _
    Handles DataGrid1.ItemCommand
    Select Case e.CommandName
    Case "Filter"
    Dim FirstName As String
    Dim TxtFilter As TextBox, CbxFilter As DropDownList, FilterValue As String
    Try
    If Left(e.CommandArgument, 3) = "Cbx" Then
    CbxFilter = CType(e.Item.FindControl(e.CommandArgument), DropDownList)
    FilterValue = CbxFilter.SelectedValue
    Else
    TxtFilter = CType(e.Item.FindControl(e.CommandArgument), TextBox)
    FilterValue = TxtFilter.Text
    End If
    If FilterValue Is Nothing Then
    Call SetupData()
    ElseIf FilterValue = String.Empty Then
    Call SetupData()
    Else
    If e.CommandArgument = "CbxFilterCategoryId" Then
    MySQLConnection.ConnectionString =_
    "Data Source=.; Initial Catalog=Northwind; User ID=sa; Password=pass@word1"
    MySQLConnection.Open()
    MySQLCommand.Connection = MySQLConnection
    MySQLCommand.CommandType = CommandType.StoredProcedure
    MySQLCommand.Parameters.Add("@CategoryId", FilterValue)
    MySQLCommand.CommandText = "SelectProductByCategoryID"
    MyDataAdapter.SelectCommand = MySQLCommand
    MyDataAdapter.Fill(MyDataSet, "Products")
    DataGrid1.DataSource = MyDataSet
    DataGrid1.DataMember = "Products"
    MySQLConnection.Close()
    ElseIf e.CommandArgument = "TxtFilterName" Then
    MySQLConnection.ConnectionString =_
    "Data Source=.; Initial Catalog=Northwind; User ID=sa; Password=pass@word1"
    MySQLConnection.Open()
    MySQLCommand.Connection = MySQLConnection
    MySQLCommand.CommandType = CommandType.StoredProcedure
    MySQLCommand.Parameters.Add("@ProductName", FilterValue)
    MySQLCommand.CommandText = "SelectProductByName"
    MyDataAdapter.SelectCommand = MySQLCommand
    MyDataAdapter.Fill(MyDataSet, "Products")
    DataGrid1.DataSource = MyDataSet
    DataGrid1.DataMember = "Products"
    MySQLConnection.Close()
    End If
    End If
    Catch ex As Exception
    Finally
    DataGrid1.DataBind()
    End Try
    End Select
    End Sub

    We reached the end and the webpage is now fully working. Go and experiment with your project and have fun. Just remember, to cancel the filter you should click the button of the name when the text box related to it is empty.

    Downloads

    Summary

    Finally, filtering is an essential part of a web application that deals with a database. Sometimes providing a user from a list of available choices is required. Another time a free text entry may be required. In this article both scenarios were implemented in a professional manner that is appealing and fast.