Binding Data to Data Web Controls

4GuysFromRolla – Binding a Scalar Array to Data Web Control

The ASP.NET data Web controls can display any data that implements either the IEnumerable interface or the IListSource interface. They are bound through two lines of codes:

  • The object is assigned to the data Web control’s DataSource property
  • The data Web control’s DataBind() method is called

The syntax for displaying a particular field in a data Web control depends upon the data Web control being used.

Two examples:

  • DataGrid
    <asp:DataGrid id="dgArrayAutoGenerate" runat="server"
           AutoGenerateColumns="True">
    </asp:DataGrid>
  • DataList
    <asp:DataList id="dlFibs" runat="server" RepeatColumns="3"
         GridLines="Both" CellPadding="10"
         RepeatDirection="Horizontal">
      <ItemTemplate>
        <b><%# Container.DataItem %></b>
      </ItemTemplate>
    </asp:DataList>

4GuysFromRolla – Admin Page

Send Emails in ASP.NET

The following two resources links shall deem useful:

In addition, the MS tutorial video below also demonstrates a way to send email:

CAPTCHA

CAPTCHA stands for “completely automated public Turing test to tell computers and humans apart”. It’s those distorted text in almost all the sites that require sign up these days, blog, emails, forums, etc.

Encrypt Configuration Information

JavaScript Better Practices

This is from a post called ASP.NET AJAX Best Priactices on CodeProject, but after reading it I’ve rather call it as titled. Here is the general summary on this very very nice article:

  • Use “var” whenever a variable is to be declared
  • Reduce scopes (Try avoiding nesting, functions or loops)
  • Use less DOM element concatenation – concatenate everything into string first, then assign to the DOM element
  • Don’t write your own method while there is one by the framework already
  • Avoid string concatenation, use Array instead – “push” each pieces of the string into array and then use “join” to get the complete string
  • Introduce function delegate
    This one is worth mentioning. When calling a function in a loop, delegate before the loop because JavaScript interpreter will use the function then as local variable and will not lookup in its scope china for the function body in each iteration
    Code: var delegate = processElement; // processElement is the function
    delegate(element1);
  • Introduct DOM elements and function caching
    Similar to function delegation. Example:
    var divContentAppendChild = $get(‘divContent’).appendChild;
    for (var i = 0; i < count; i++)
    divContentAppendChild(element[i]);
  • Avoid using switch if possible, as JavaScript interpreter can’t optimize switch block.

ASP.NET Membership

ASP.NET Security Tutorials

There are so much information on ASP.NET Membership/Roles/Login/Profile, as you might have noticed the number of posts I gathered under the “Membership” category. Our of everything, Microsoft’s official Security tutorials would be the place I choose to start, and more of these tutorials are still actively being added.

  1. Security Basics and ASP.NET Support
  2. An overview of Forms Authentication
  3. Forms Authentication Configuration and Advanced Topics
  4. Creating the Membership Schema in SQL Server
  5. Creating User Accounts
  6. Validating User Credentials Against Membership User Store
  7. User-Based Authorization
  8. Storing Additional User Information
  9. Creating and Managing Roles
  10. Assigning Roles to Users
  11. Role-Based Authorization
  12. Building an Interface to Select One User Account from Many
  13. Recovering and Changing Passwords
  14. Unlocking and Approving User Accounts

$get & $find

From Mr. Matt Berseth’s blog… everything you need to know…

The Ever-Useful $get and $find ASP.NET AJAX Shortcut Functions

Posted in General. 1 Comment »

Login Controls

There are 7 Login Controls in Visual Studio Web Developer 2008 Express Edition.

ASP.NET Login Controls Overview

  1. Login – provides user interface (UI) elements for logging in to a Web site.
  2. LoginView – displays the appropriate content template for a given user, based on the user’s authentication status and role membership.
  3. PasswordRecovery – provides user interface (UI) elements that enable a user to recover or reset a lost password and receive it in e-mail.
  4. LoginStatus – detects the user’s authentication state and toggles the state of a link to log in to or log out of a Web site.
  5. LoginName – displays the value of the System.Web.UI.Page.User.Identity.Name property
  6. CreateUserWizard – provides a user interface for creating new Web site user accounts.
  7. ChangePassword – provides a user interface that enable users to change their Web site password.