Categories: Tutorials

Using ASP.NET Controls in SharePoint

3 min read

ASP.NET controls

We can view the controls that are available by opening up the Toolbox task pane and maximizing the ASP.NET Controls option. Within this option, there are six categories of controls. Of these, we can ignore the WebParts option because that is simply a link to the Web Parts task pane.

It should be noted that it is not possible to use ASP.NET WebParts in SharePoint 2007 sites. It is, however, possible for developers to create their new user controls as SmartParts (see http://www.codeplex.com/smartpart) to allow them to be included within WSS and MOSS sites.

The five remaining categories are:

Standard controls

This contains a large number of controls. Most of these are simple, for example:

  • The Image control, which displays a picture.
  • The Label control, which displays text.
  • The Hyperlink control, which we will use to link from our homepage shortly.

In addition, we have standard controls that are somewhat more exciting:

  • The FileUpload control allows files to be uploaded to the server from the user’s computer.
  • The Wizard control allows a multi-step form to be added to our site. At each step of the wizard, the user is asked for different information.
  • The Xml control allows data from an XML document to be displayed on our page (although you may find it easier to use a Data View to display the contents of your XML file).
  • The Calendar control, which we will also add to our site later in this article.

Data controls

The data controls allow us to connect to various different data sources, display the results on our page, and update the data in the source.

Because SharePoint already provides us with access to data sources in the Data Source Library task pane, we can safely ignore these controls.

Validation controls

The validation controls allow us to validate information input by the user. We will see this in practice towards the end of the article, when we add validation to a form.

Navigation controls

The navigation controls provide us with three different methods of helping users navigate our site. The Menu and TreeView controls would allow users to browse to a particular page, while the SiteMapPath control displays breadcrumbs that show their position within the page hierarchy. We will see an example of the Menu control later in this article.

Login controls

The login controls allow us to take advantage of ASP.NET’s extensive membership provider system. The benefit of this is that we no longer need to manually create all the elements required by a login system (i.e. registration, login, password reminder, etc.). We will also look at this in detail in this article.

Further information about virtually all of the ASP.NET server controls, including examples and code snippets, is available in the ASP.NET Control Reference in the .NET Framework SDK, which is available at.

Adding a simple control

In this article, we will be using various server controls in our pages.

We will start by adding one of the simplest controls to our homepage:

  1. Open the share site in SharePoint Designer.
  2. Open the default.aspx page in Design view.
  3. Make sure that the Standard controls are visible in the Toolbox task pane.
  4. Click on the HyperLink control and drag it onto our page.
  5. Right-click on the control that we have just placed and select Properties from the shortcut menu. This will open the Tag Properties task pane to the left of our design window.
  6. Type View Orders Graph into the Text field in the Tag Properties task pane.
  7. Click on the ellipsis to the right of the NavigateUrl field and select orders.aspx from the list of pages.
  8. Finally, save the page.

The following image shows the Properties shortcut menu that we see as we work through this process:

Now, when we open http://olmec/share/ in our browser, we see that the default page links to the Order Graphs.

Packt

Share
Published by
Packt

Recent Posts

Top life hacks for prepping for your IT certification exam

I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…

3 years ago

Learn Transformers for Natural Language Processing with Denis Rothman

Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…

3 years ago

Learning Essential Linux Commands for Navigating the Shell Effectively

Once we learn how to deploy an Ubuntu server, how to manage users, and how…

3 years ago

Clean Coding in Python with Mariano Anaya

Key-takeaways:   Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…

3 years ago

Exploring Forms in Angular – types, benefits and differences   

While developing a web application, or setting dynamic pages and meta tags we need to deal with…

3 years ago

Gain Practical Expertise with the Latest Edition of Software Architecture with C# 9 and .NET 5

Software architecture is one of the most discussed topics in the software industry today, and…

3 years ago