Rhonda Tipton’s WebLog

Random Subject Matters

Archive for the 'ASP.NET' Category


Tutorials for C# and ASP.NET

Posted by Rhonda Tipton on October 21, 2007

There are many sites that contain great tutorials for C# and ASP.NET. Below are the ones that I have found useful.

The BlackWasp website is great. They have some very useful C# tutorials that they continually add to.

Coder Source also has some good C# Basics and Tutorials available.

When it comes to ASP.NET, I believe the best tutorials can be found in the Learn area of the ASP.NET website; however, there is some good material in the ASP.NET section of the W3Schools website as well.

In closing, there is a huge amount of beginner .NET content online, the sites that I have listed above are ones that have helped me the most. If anyone knows of anymore great tutorial sites, feel from to let me know.

Posted in ASP.NET, C#, Recommendations | No Comments »

Great Series on ASP.NET and Data Access

Posted by Rhonda Tipton on August 8, 2007

Scott Mitchell has posted a series of articles on the 4 Guys From Rolla website titled Accessing and Updating Data in ASP.NET 2.0. The series is thorough and easy to follow. Some of the topics include Data Source Control Basics, Accessing Data, Retrieving XML Data and Inserting/Deleting/Updating data. There are several other articles.

There is also feed to the article series available. I highly recommend subscribing as it is a great series for anyone learning ASP.NET.

Wow, I just found a plethora of information on the subject of ASP.NET and Data Access on Scott’s blog as well as the ASP.NET website. This guy has been working really hard on this stuff and, in my opinion, has done a wonderful job.

Direct Links
The Remaining 9 “Working with Data in ASP.NET 2.0″ Tutorials - via Scott’s Blog
5 New “Working with Data in ASP.NET 2.0″ Tutorials Available - via Scott’s Blog
4 New “Working with Data in ASP.NET 2.0″ Tutorials Available - via Scott’s Blog
Working with Data in ASP.NET 2.0 - Complete!
Data Access Tutorials - via ASP.NET

The tutorials are available in both VB.NET and C#. I may be repeating some of the links, but there is so much material that I want to make sure I include everything.

“I am learning all the time. The tombstone will be my diploma.” ~Eartha Kitt

Posted in ASP.NET, Recommendations | 1 Comment »

ASP.NET Calendar Class

Posted by Rhonda Tipton on March 18, 2007

The Calendar class displays a single month calendar that allows the user to select dates and move to the next or previous month. It is part of the System.Web.UI.WebControls namespace.

There are several style properties (color, border, cell, etc) that can be set to change the look and feel of the control. Below are the most useful (non-style) properties.

DayNameFormat
Gets or sets the name format of days of the week.

FirstDayOfWeek
Gets or sets the day of the week to display in the first day column of the Calendar control.

SelectedDate
Gets or sets the selected date.

SelectedDates
Gets a collection of System.DateTime objects that represent the selected dates on the Calendar control.

SelectionMode
Gets or sets the date selection mode on the Calendar control that specifies whether the user can select a single day, a week, or an entire month.

TodaysDate
Gets or sets the value for today’s date.

VisibleDate
Gets or sets the date that specifies the month to display on the Calendar control.

Simple Example of the Calendar Control

ASP.NET SOURCE

<asp:Calendar
   ID=”Calendar1″ runat=”server”
   BackColor=”#FFFFCC” BorderColor=”#FFCC66″
   BorderWidth=”1px”
   DayNameFormat=”Shortest”
   Font-Names=”Verdana” Font-Size=”8pt”
   ForeColor=”#663399″ Height=”200px”
   ShowGridLines=”True” Width=”220px”
   OnSelectionChanged=”Calendar1_SelectionChanged”>
   <SelectedDayStyle BackColor=”#CCCCFF” Font-Bold=”True” />
   <TodayDayStyle BackColor=”#FFCC66″ ForeColor=”White” />
   <SelectorStyle BackColor=”#FFCC66″ />
   <OtherMonthDayStyle ForeColor=”#CC9966″ />
   <NextPrevStyle Font-Size=”9pt” ForeColor=”#FFFFCC” />
   <DayHeaderStyle BackColor=”#FFCC66″
      Font-Bold=”True” Height=”1px” />
   <TitleStyle BackColor=”#990000″
      Font-Bold=”True” Font-Size=”9pt”
      ForeColor=”#FFFFCC” />
</asp:Calendar>

C# SOURCE

using System.Web;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
  protected void Page_Load(object sender, EventArgs e)
  {
      Label1.Text = Calendar1.TodaysDate.ToString();
  }
  protected void Calendar1_SelectionChanged(object sender, EventArgs e)
  {
      Label1.Text = Calendar1.SelectedDate.ToString();
  }
}

RESULT

The Calendar control is a rich control that can be extended much further. Online appointment calendars and event calendars are just the beginning.

Posted in ASP.NET | No Comments »

Using the app_offline.htm in ASP.NET

Posted by Rhonda Tipton on February 4, 2007

The app_offline.htm can be used as a nice & clean way to tell the people that access your website when it is down for maintenance tasks. Scott Guthrie talks about this very helpful feature of ASP.NET 2.0 here and also here.

Basically, when you do not want anyone to access your site, you place a file named app_offline.htm in the root of your web application. When users access your site, they will see the rendered contents of the app_offline.htm file. You can have it display a very simple message like “This site is down for maintenance”. Once the maintenance is complete, simply delete or rename the file.

This is my offline page -

Now I just need to remember to rename the app_offline.htm file when I am finished working on the site.

Posted in ASP.NET | No Comments »

ASP.NET 2.0’s Membership, Roles, and Profiles

Posted by Rhonda Tipton on January 12, 2007

There is a very informative eight-part article series from Scott Mitchell on ASP.NET 2.0’s Membership, Roles, and Profiles.

I tend to gravitate toward artices on the 4 Guys from Rolla website because they contain an abundant amount of great information for developers of all levels. This article series is a prime example of the material available on their website.

Posted in ASP.NET | No Comments »

Consuming Web Services in .NET

Posted by Rhonda Tipton on January 1, 2007

A Web Service is a software that is designed to support the interaction of diverse systems over the internet. A WSDL (Web Services Description Language) file is used to describe the web service.

There are several places to find free web services to consume on your website. One such place is a site called XMethods. This site has many “ready to consume” web services. For example, there are web services to retrieve stock quotes as well as services to retrieve weather information for a given zip code.

The one I chose to use in this post is the .NET Factoid web service. (WSDL File)

To enable your web application to consume this web service, you must first add a reference to the service.

  • Right-Click on the web project and select Add Web Reference…
  • In the Add Web Reference dialog box, type the url to the WSDL file for the desired service and click Go
  • Change the Web Reference Name to something descriptive and click Add Reference

You should now see the following in your web project:

After doing all of the prep work, the service is ready to be consumed by your web application.

In this case, I added a label control to the ASPX page and put the following code in my code-behind:

using System;
using System.Web.Services.Protocols;
using DotNetFacts;

public partial class AppDevl : System.Web.UI.Page
{
  protected void Page_Load(object sender, EventArgs e)
  {
    if (!Page.IsPostBack)
    {
      DotnetDailyFact fact = new DotnetDailyFact();
      string dayFact = fact.GetDotnetDailyFact();
      lblFact.Text = dayFact;
    }
  }
}

Below is what it looks like on my website:

Amazon also provides consumable web services (must have a free Amazon account). Using a post from Mads Kristensen, I created an interface that consumes an Amazon web service and pulls the album or book cover for a given author and title.

For more detail on the Amazon Web Service, see Mads Kristensen’s post - Download album art for free through a web service.

As you can see there are Web Services available in many places on the internet. In the future, I will also discuss creating Web Services.

Posted in ASP.NET | No Comments »

Playing with Themes in ASP.NET

Posted by Rhonda Tipton on December 4, 2006

In this post, I will be going through a basic example of utilizing Themes in ASP.NET. They are very easy to setup and use.

Basically, themes set the look and feel of the controls contained in the website.

First, add folder to the Website project called App_Themes. Then add a new item –> Skin file and name it TestSkin.skin

This creates a TestSkin folder underneath the App_Themes folder that contains the skin file.

Set a couple of common controls and save the file. (TestSkin.skin)(See below)

ASP.NET CODE (Skin file)

<asp:Label
    runat=”server”
    BackColor=”Green”
    ForeColor=”White”
    font-size=”8″
    font-name=”Tahoma” />

<asp:Button
    runat=”server”
    font-size=”8″
    font-name=”Tahoma”
    font-bold=”True”
    ForeColor=”Orange” />

<asp:DropDownList
    runat=”server”
    font-size=”8″
    font-name=”Tahoma”
    ForeColor=”Red” />

Go to the Page Directive of the page you want the theme to be applied to and add the Theme attribute

ASP.NET CODE (Aspx file)

<%@ Page Language=”C#” AutoEventWireup=”true”
        CodeFile=”Default.aspx.cs” Theme=”TestTheme” Inherits=”_Default” %>

Once you save everything and view it in the browser, you can see that the controls take on the characteristics set in the theme/skin file.

RESULT

This is a very basic example, but themes can help make multiple pages look like an integrated web application. There is so much that can be done using themes in ASP.NET.

[-Related Links-]
Code in Style with ASP.NET Themes
Themes and Skins in ASP.NET 2.0
Colorful ASP.NET Themes
Using Themes to Customize a Site

Posted in ASP.NET | No Comments »

BulletedList Control in ASP.NET

Posted by Rhonda Tipton on November 27, 2006

There are several list controls available to ASP.NET. They are the DropDownList, ListBox, CheckBoxList, RadioButtonList and BulletedList controls. The one I will go over in this post is the BulletedList control.

The ASP.NET BulletedList control is used to create a defined list of items formated with bullets. Each item in a BulletedList control is considered a ListItem element. This control can be loaded manually through ASP.NET code (like my example) as well as from a data source.

The BulletedList control is part of the System.Web.UI.WebControls namespace.

Most common properties

DisplayMode
Gets or sets the display mode of the list content in a BulletedList control

BulletStyle
Gets or sets the bullet style for the BulletedList control

BackColor/ForeColor
Gets or sets the back/foreground color of the web server control

Border Color/Style/Width
Gets or sets the border color/style/width of the web server control

Font
Gets the font properties associated with the web server control

-

The BulletedList control has three display types:

  • Hyperlink
  • LinkButton
  • Text

-

The following BulletStyles are available for the BulletedList control:

  • Circle - Hollow Circle
  • Disc - most common Bullet
  • LowerAlpha - Letters
  • LowerRoman - Roman Numerals
  • Numbered
  • Square
  • UpperAlpha - Letters
  • UpperRoman - Roman Numerals
  • CustomImage

-

Simple Example of the BulletedList Control

This example fills the control to display.

ASP.NET SOURCE

Below are the current planets in our Solar System.<br />

<asp:BulletedList ID=blPlanets BulletStyle=”Square” runat=server>
    <asp:ListItem>Mercury</asp:ListItem>
    <asp:ListItem>Venus</asp:ListItem>
    <asp:ListItem>Earth</asp:ListItem>
    <asp:ListItem>Mars</asp:ListItem>
    <asp:ListItem>Jupiter</asp:ListItem>
    <asp:ListItem>Saturn</asp:ListItem>
    <asp:ListItem>Uranus</asp:ListItem>
    <asp:ListItem>Neptune</asp:ListItem>
</asp:BulletedList>

C# SOURCE

You can also fill the BulletedList control dynamically using the Page load event instead of ASP.NET code.

protected void Page_Load(object sender, EventArgs e)
{
  if (!Page.IsPostBack)
  {
    blPlanets.Items.Add(“Mercury”);
    blPlanets.Items.Add(“Venus”);
    blPlanets.Items.Add(“Earth”);
    blPlanets.Items.Add(“Mars”);
    blPlanets.Items.Add(“Jupiter”);
    blPlanets.Items.Add(“Saturn”);
    blPlanets.Items.Add(“Uranus”);
    blPlanets.Items.Add(“Neptune”);
  }
}

RESULT

-

This post concludes my List Control series. There are many other methods of implementing the different List Controls in ASP.NET. I have barely scratched the surface of possibilities.

-

[- Related Links -]
ASP.NET Quickstart Tutorials - BulletedList
ASP.NET Tutorial - BulletedList

Posted in ASP.NET | No Comments »

RadioButtonList Control in ASP.NET

Posted by Rhonda Tipton on November 27, 2006

There are several list controls available to ASP.NET. They are the DropDownList, ListBox, CheckBoxList, RadioButtonList and BulletedList controls. The one I will go over in this post is the RadioButtonList control.

The ASP.NET RadioButtonList control is used to create a defined list of options in which a user can choose from. Like the DropDownList control, only one item can be selected at a time. Each selectable item in a RadioButtonList control is considered a ListItem element. This control can be loaded manually through ASP.NET code (like my example) as well as from a data source.

The RadioButtonList control is part of the System.Web.UI.WebControls namespace.

Most common properties

AutoPostBack
A Boolean value that specifies whether the form should be posted immediately after one of the items changes select status or not.

CellPadding
The space, in pixels, between the cell walls and the radio button group

DataSource
The data source to use

DataTextField
A field in the data source to be displayed in the radio button group

DataValueField
A field in the data source that specifies the value of each selectable item in the radio button group

id — A unique id for the control

OnSelectedIndexChanged
The name of the function to be executed when one of the items changes select status

RepeatColumns
The number of columns to use when displaying the radio button group.

RepeatDirection
Specifies whether the radio button group should be repeated horizontally or vertically. Legal values are “Horizontal” and “Vertical”.

RepeatLayout
The layout of the radio button group. Can be “Table” or “Flow”.

runat
Specifies that the control is a server control. Must be set to “server”

TextAlign
On which side of the radio button the text should appear (right or left)

-

Simple Example of the CheckBoxList Control

This example fills the control and displays the Selected Item in a label control when the button is accessed.

ASP.NET SOURCE

<asp:RadioButtonList ID=”rblPlanets” runat=”server” Width=”109px”>
    <asp:ListItem Value=”1″>Mercury</asp:ListItem>
    <asp:ListItem Value=”2″>Venus</asp:ListItem>
    <asp:ListItem Value=”3″>Earth</asp:ListItem>
    <asp:ListItem Value=”4″>Mars</asp:ListItem>
    <asp:ListItem Value=”5″>Jupiter</asp:ListItem>
    <asp:ListItem Value=”6″>Saturn</asp:ListItem>
    <asp:ListItem Value=”7″>Uranus</asp:ListItem>
    <asp:ListItem Value=”8″>Neptune</asp:ListItem>
</asp:RadioButtonList>

C# SOURCE

protected void btnSubmit_Click(object sender, EventArgs e)
{
  lblText.Text = “You selected: “ + rblPlanets.SelectedItem.Text;
}

You can also fill the RadioButtonList control dynamically using the Page load event instead of ASP.NET code.

protected void Page_Load(object sender, EventArgs e)
{
  if (!Page.IsPostBack)
  {
    rblPlanets.Items.Add(“Mercury”);
    rblPlanets.Items.Add(“Venus”);
    rblPlanets.Items.Add(“Earth”);
    rblPlanets.Items.Add(“Mars”);
    rblPlanets.Items.Add(“Jupiter”);
    rblPlanets.Items.Add(“Saturn”);
    rblPlanets.Items.Add(“Uranus”);
    rblPlanets.Items.Add(“Neptune”);
  }
}

protected void btnSubmit_Click(object sender, EventArgs e)
{
  lblText.Text = “You selected: “ + rblPlanets.SelectedItem.Text;
}

RESULT

As I mentioned at the beginning of this post, there are several list controls in ASP.NET. I plan on touching on the other list controls in future posts.

Related Content

Posted in ASP.NET | No Comments »

CheckBoxList Control in ASP.NET

Posted by Rhonda Tipton on November 24, 2006

There are several list controls available to ASP.NET. They are the DropDownList, ListBox, CheckBoxList, RadioButtonList and BulletedList controls. The one I will go over in this post is the CheckBoxList control.

The ASP.NET CheckBoxList control is used to create a defined list of options in which a user can choose from. With this control, you can select one item or multiple items. Each selectable item in a CheckBoxList control is considered a ListItem element. This control can be loaded manually through ASP.NET code (like my example) as well as from a data source.

The CheckBoxList control is part of the System.Web.UI.WebControls namespace.

Most common properties

AutoPostBack
A Boolean value that specifies whether the form should be posted immediately after one of the items changes select status or not.

CellPadding
The space, in pixels, between the cell walls and the check box group

DataSource
The data source to use

DataTextField
A field in the data source to be displayed in the check box group

DataValueField
A field in the data source that specifies the value of each selectable item in the check box group

id — A unique id for the control

OnSelectedIndexChanged
The name of the function to be executed when one of the items changes select status

RepeatColumns
The number of columns to use when displaying the check box group.

RepeatDirection
Specifies whether the check box group should be repeated horizontally or vertically. Legal values are “Horizontal” and “Vertical”.

RepeatLayout
The layout of the check box group. Can be “Table” or “Flow”.

runat
Specifies that the control is a server control. Must be set to “server”

TextAlign
On which side of the check box the text should appear (right or left)

-

Simple Example of the CheckBoxList Control

This example fills the control and displays the Selected Item in a label control when the button is accessed.

ASP.NET SOURCE

<asp:CheckBoxList ID=”cblPlanets” runat=”server” Width=”109px”>
    <asp:ListItem Value=”1″>Mercury</asp:ListItem>
    <asp:ListItem Value=”2″>Venus</asp:ListItem>
    <asp:ListItem Value=”3″>Earth</asp:ListItem>
    <asp:ListItem Value=”4″>Mars</asp:ListItem>
    <asp:ListItem Value=”5″>Jupiter</asp:ListItem>
    <asp:ListItem Value=”6″>Saturn</asp:ListItem>
    <asp:ListItem Value=”7″>Uranus</asp:ListItem>
    <asp:ListItem Value=”8″>Neptune</asp:ListItem>
</asp:CheckBoxList>

C# SOURCE

protected void btnSubmit_Click(object sender, EventArgs e)
{
  lblText.Text = “You selected: “;
  foreach (ListItem li in cblPlanets.Items)
  {
     if (li.Selected == true)
     {
        lblText.Text = lblText.Text += “~” + li.Text;
     }
   }
}

You can also fill the CheckBoxList control dynamically using the Page load event instead of ASP.NET code.

protected void Page_Load(object sender, EventArgs e)
{
  if (!Page.IsPostBack)
  {
    cblPlanets.Items.Add(“Mercury”);
    cblPlanets.Items.Add(“Venus”);
    cblPlanets.Items.Add(“Earth”);
    cblPlanets.Items.Add(“Mars”);
    cblPlanets.Items.Add(“Jupiter”);
    cblPlanets.Items.Add(“Saturn”);
    cblPlanets.Items.Add(“Uranus”);
    cblPlanets.Items.Add(“Neptune”);
  }
}

protected void btnSubmit_Click(object sender, EventArgs e)
{
  lblText.Text = “You selected: “;
  foreach (ListItem li in cblPlanets.Items)
  {
    if (li.Selected == true)
    {
      lblText.Text = lblText.Text += “~” + li.Text;
    }
  }
}

RESULT

-

As I mentioned at the beginning of this post, there are several list controls in ASP.NET. I plan on touching on the other list controls in future posts.

Related Content

Posted in ASP.NET | No Comments »