Designing websites for accessibility in Expression Web – Part I

Have you ever come across a requirement where you have to create web content that is accessible to people with disabilities? If yes, then you may find this article useful, if not, then the article will help you understand why your websites need to be accessible and how to go about making them accessible. Lets us understand the importance of accessibility and see how to get that in our websites.
Accessibility is a vast topic and there are many aspects to be considered while creating an accessible website. In this article, I have tried to touch upon some important points to be considered while making you website accessible.
What is website accessibility?
There are many definitions of web accessibility. I find this definition simple to understand – ‘a practice to make websites usable to people of all abilities and disabilities’. People with disabilities may be visually impaired so may not be able to see your pages or hearing impaired will not be able to listen to your podcasts or those who are immobile may not be able to use their mouse or keyboard.
When you design a website, you need to consider making your website accessible to all the users especially those with disabilities, so that they can understand and interact with the web.
How to create accessible websites?
To create an accessible website, means to create web content that is accessible for all type of users. First you create the web content and then you test it for accessibility. For better understanding, I have divided this topic into two parts. In this article (Part I) I will show you how to make you content accessible and in the next part of the article, we will see how to check the content for accessibility.
To make you content accessible, follow these tips:
Setting accessibility properties for an image
Whenever you insert an image in your web page, Expression Web prompts you with an Accessibility Properties dialog box as shown below:
accessibility_properties
Alternate text or alt text is a textual alternative to the image which makes it accessible to the screen reader users. Another usage of alternate text is, if an image is being downloaded on the page or when image cannot be found and user hovers over the placeholder of the image, a small piece of text would explain what the image is about.
This Accessibility Properties dialog box is prompted every time you insert an image on your page, unless you uncheck the option ‘ Show this prompt when inserting images’ (see image above). On the other hand, to add an alternate text to an existing image, you can double click the image in Design view and in the Picture Properties dialog box (shown below) and in the Accessibility section, insert the Alternate text.
picture_properties
Alternatively, you can always set the alt attribute of the <img> tag to describe the image. And similarly, add an alt attribute to any animations on your page.
Setting accessibility properties for text hyperlinks and hotspots
Text Hyperlinks:
a. Select the text you want to convert into a hyperlink and right click on it.
b. From the menu choose Hyperlink…
c. In the Insert Hyperlink dialog box, click on ScreenTip…
insert_hyperlink
d. Enter the ScreenTip text which acts like the alternate text. This will add a title attribute to the <a> tag.
In addition to above, Hyperlink text should be short meaningful and should make sense when read out of context, either particularly that link or along with other links.
Image maps:
Just as you add screen tips to text hyperlinks to make them accessible, use them to make the hotspots accessible too. Follow these steps:
a. Insert the image onto your web page.
b. In the Pictures toolbar (if not visible, right click on any toolbar and choose Pictures from the menu) choose rectangular or circular hotspot.
c. Draw a hotspot on the image.
d. The Insert Hyperlink dialog box pops up as shown above.
e. Click on the ScreenTip… button to insert the screen tip. This will add a title attribute to the <area> tag.
Creating accessible Tables
Though tables can be used in page layouts, they are best used to organize data. CSS should be used for Page layouts and styles.
NOTE: Expression Web has a set of layout tables that you can use to create page layouts. Using them is quite simple.
Have you ever come across a requirement where you have to create web content that is accessible to people with disabilities? If yes, then you may find this article useful, if not, then the article will help you understand why your websites need to be accessible and how to go about making them accessible. Lets us understand the importance of accessibility and see how to get that in our websites.
Accessibility is a vast topic and there are many aspects to be considered while creating an accessible website. In this article, I have tried to touch upon some important points to be considered while making you website accessible.
Image maps:
Just as you add screen tips to text hyperlinks to make them accessible, use them to make the hotspots accessible too. Follow these steps:
a. Insert the image onto your web page.
b. In the Pictures toolbar (if not visible, right click on any toolbar and choose Pictures from the menu) choose rectangular or circular hotspot.
c. Draw a hotspot on the image.
d. The Insert Hyperlink dialog box pops up as shown above.
e. Click on the ScreenTip… button to insert the screen tip. This will add a title attribute to the <area> tag.
Creating accessible Tables
Though tables can be used in page layouts, they are best used to organize data. CSS should be used for Page layouts and styles.
NOTE: Expression Web has a set of layout tables that you can use to create page layouts. Using them is quite simple.
Table accessibility is all about adding appropriate headers to data tables. Header tags solve the purpose. Header tags <th> should be descriptive enough to describe what the table is about. Table headers are recognized by most of the browsers and rendered as bold and centered. These cause them to be visually effective to the users.
NOTE: TableHeaders should be used only for data tables and not for layouts.
To create table headers follow these steps:
a. After inserting a table, choose a cell and right click.
b. Choose Cell Properties to open the Cell Properties dialog box.
cell_properties
c. Check the box ‘Header cell’ and click OK.
d. This will convert the <td> tags to <th> tags.
e. Enter a table header.
Creating accessible Forms
Forms are extensively used by websites either as contact forms, search forms; online shopping websites have forms to buy products, or airline booking forms and such other. Accessibility in forms is an extensive area in itself as forms are not very simple to navigate for people with disabilities. I will cover Form accessibility in detail in one of my future articles, however over here I will give you some tips you may find useful in order to make your forms accessible.
1. Labels: Labels are used to assign a label to any form control. Use the ‘for’ attribute to specify which form control is it associated with and ‘id’ attribute to assign a unique id. Make sure labels are close to the form elements.
2. Text fields and areas: It is very difficult for blind users to interpret what to enter in a text field/area. So enter a label for the text fields.
3. Radio buttons and Checkboxes: They are similar to the text fields but the text is displayed on the right hand side. A common example for radio button would be gender. You could use a group box for such examples to group the options to be chosen in a section. Group box is explained further in this list.
4. Input buttons: Input buttons could be a normal button, submit button or reset button. The value attribute for these buttons is important so that when a user hits the tab key to get to this button, when it gets focus, it will be highlighted with a dotted border. In case of a user using a screen reader or a talking browser, it announces the text on the button.
5. Image buttons: Enter an alt attribute for the image button.
6. Group box: A group box enters a set of <fieldset> and <legend> tags. See the code below:
<fieldset name=”Group1″>
<legend>Group box</legend>
</fieldset>
Fieldsets: The fieldset tag helps to group form elements such as address line 1, address line 2 and address line 3. The fieldset tag draws a box around its containing elements and groups them.
Legend tag: is used along with the <fieldset> tag to add a title to the element group and place it within the frame.
7. Select menus or Drop down boxes: The <select> tag allows you to group choices, a drop down. Provide an appropriate label to it.
Creating accessible Frames
Frames are used to display two or more web pages in a single visual space. To be able to make these frames accessible, add a title to each frame. This will help the screen reader users to listen to the title of each of these frames, helping them to know what each frame displays.
The content in the <noframes> tag should be always available to the users. You can use the <noframes> tag to tell the users what is being displayed in the frames and also give them links to the individual pages displayed in frames, in case they want to visit.
Conclusion
Accessibility is a vast topic and there are many aspects to be considered while creating an accessible website. In this article, I have tried to touch upon some important points to be considered while making you website accessible. I hope the article was helpful to you. In the next article we will check the accessibility of the websites using the Accessibility Checker feature available in Expression Web.
Anúncios

Using Dynamic Views In ASP.NET MVC 2

A really cool addition to ASP.NET MVC 2 is the ability to use the dynamic type as the object passed into the view. This is also known as a dynamic view. If you create a new view and don’t create a strongly typed view, out of the box, the MVC framework will make the view inherit from the ViewPage class, but the generic type will be dynamic, like this:

<%@Page Language=”C#” MasterPageFile=”~/Views/Shared/ViewMasterPage.Master” Inherits=”System.Web.Mvc.ViewPage”
<dynamic>”%>

Using the dynamic type is good because it allows you to create your objects on the fly. The downside of this is because the view is not strongly typed, you don’t get the compile time checking. For me compile time checking is a compelling reason to use strongly typed views.
In this example, I’m going to pass a collection of time zones into the view as a dynamic object to the view. To see this in action, I’m going to create a small ASP.NET MVC 2 website. If you haven’t got Microsoft Visual Studio 2010, you can download the Express edition here.
To begin, let’s add the view straight away. Normally you would do this after you have defined your action, but that’s not the focus of this article. By adding a view that is not strongly, we get to use the dynamic type. Here’s the view:
AddView
The HTML that’s added inherits from the ViewPage class, but the generic type is dynamic:
<%@Page Title=”” Language=”C#” MasterPageFile=”~/Views/Shared/ViewMasterPage.Master” Inherits=”System.Web.Mvc.ViewPage”
<dynamic>”%>
Cool huh?! Now I can add a dynamic object. I’m going to be displaying the list of time zones on your computer in a drop down list. Here’s the code:
<asp:ContentID=”Content2″ ContentPlaceHolderID=”MainContent” runat=”server”>
<%:Html.DropDownList(“DisplayName”,(IEnumerable=””
<SelectListItem> )Model.TimeZones) %>
</asp:Content>
I can access the dynamic type via the Model property which is available to the view by default. If you compiled this now, even though I haven’t created a real object, it will still compile.
Ok let’s add code to the controller to return the list of time zones. I’m adding this to the HomeController. Here’s the code below:
C#

public ActionResult GetTimeZones()
{
dynamic viewData = new ExpandoObject();
viewData.TimeZones = from p in TimeZoneInfo.GetSystemTimeZones()
select new SelectListItem
{
Text = p.DisplayName,
Value = p.Id
};
return View(“Index”, viewData);
VB.NET

Public Function GetTimeZones() As ActionResult
Dim viewData As Object = New ExpandoObject()
viewData.TimeZones = From p In TimeZoneInfo.GetSystemTimeZones()

Executar aplicações em background com Agendador de Tarefas Windows

Às vezes precisamos executar algumas aplicações em background, ou seja, sem que o usuário saiba disso. Alguns processos como integrações ou carga de dados.

Uma forma bem simples de se fazer isso é utilizar o Agendador de tarefas do próprio Windows localizado em: Painel de Controle\Todos os Itens do Painel de Controle\Ferramentas Administrativas.
image1

Para testar, vamos fazer uma aplicação console no Visual Studio. Abra o Visual Studio acesse File\New\Project e escolha o projeto Console Application conforme imagem 01.

A idéia é fazer uma aplicação que irá gerar um arquivo txt que irá registrar a hora atual.

Vamos mudar algumas opções para que a aplicação console seja executada sem exibir a janela do prompt do DOS.

Acesse as propriedades do projeto clicando com o botão direito do mouse no projeto e em propriedades conforme a imagem 02.
image2

Na guia application mude a opção Output Type para Windows Application conforme a imagem 03:
image3

Agora vamos programar para gerar o arquivo txt.  Na classe Program.cs digite o seguinte código no método Main:
image4

Pronto, temos uma aplicação console que gerar um arquivo txt salvado a hora atual, agora vamos compilar e gerar o executável.

Vamos agendar para que esse executável seja executado pelo agendador de tarefa. Após abrir o agendador de tarefa, clique na opção “Criar Tarefa ” no menu Ações localizado do lado direito.

A janela “Criar Tarefa será exibida”. De um nome para a tarefa, no meu caso “Executar aplicações em background com Agendador de Tarefas Windows” e clique na aba Disparadores. Clique em Novo e faça as configurações conforme a imagem abaixo:
image5
Acabamos de configurar a hora e a quantidade de vezes que o agendador de tarefa será executado. Clique em OK e acesse a guia Ações. Clique em Novo e a janela “Nova Ação” será exibida. Deixe a opção Iniciar um Programa na opção Ação e em Programa/script localize o nosso executável. Clique em OK. Pronto agora a cada um minuto o arquivo txt receberá a informação.

Perceba que o arquivo é modificado, porém, nenhuma janela e exibida para o usuário.

Recomendo pesquisas sobre o Agendador de Tarefa que existem outras opções como enviar e-mail.

Create WPF Master – Detail UI Using Data Sources Window Object DataSource

This article has a corresponding video that can be viewed here.

Master – Detail layouts are the bread and butter of Line of Business (LOB) applications. This walkthrough will show you how to drag & drop from the Data Sources Window to create the UI that is sourced from an Object DataSource.

This article has a C# and VB.NET download that includes both a completed solution and a starter solution. The starter solution includes the data entity classes and a static (Shared) data source class.

This walkthrough assumes that you’ll be starting with the starter solution.

Table of Contents

  1. Completed Application
  2. Starter Solution
  3. Adding a Title to the Form
  4. Adding the ComboBox Used for Record Selection
  5. Adding the Details Form
  6. Adding the DataGrid
  7. How does it Work?
  8. Comments

Completed Application 

Figure 1 Completed Application

Starter Solution 

Open the accompanying (C# or VB.NET) starter solution.

Figure 2 Starter Solution

The Data class provides two static (Shared) properties that expose an ObserveableCollection that the application will use as its data source. The Data class takes the place of a data layer that would be used to populate CLR classes from a database.

Figure 3 Data Class Diagram

The Customer class can contain one or more Addresses. Each Address has an associated AddressType.

Figure 4 Entity Class Diagram

Adding a Title to the Form 

Step One

Figure 5 Draw Border

  • Build the solution
  • Open ApplicationMainWindow.xaml
  • Select the root Grid by clicking inside the Window
  • Create a new Grid Row that takes up about 25% of the Window by
    • Click the Grid rail on the left to create a new row
  • Draw a Border control inside the new row
    • Select the Border control in the Toolbox then draw the Border as pictured in Figure 5 above

Step Two

  • Draw a TextBlock control inside the Border
  • Multi-select the TextBlock and Border controls using either the Document Outline or by CTRL + clicking each control
    • Right click, select Reset Layout, All
    • This will reset the Width, Height, HorizontalAlignment and VerticalAlignment properties to their default values

 ResetBorderTextBlockLayout

Figure 6 Reseting Values

  • After properties are reset your Window should look like Figure 7 below

Figure 7 Title Step Two

Step Three

  • Using the Document Outline, select the Border control
  • Using the Properties Window set the following properties:
    • CornerRadius to 30
    • Margin to 11
    • Padding to 7
    • BorderThickness to 2
    • Background to formTitleBackgroundBrush
      • Use Resource Picker, see Figure 8 below.  After opening Resource Picker, select formTitleBackgroundBrush.
    • BorderBrush to formTitleBorderBrush
      • Use Resource Picker, see Figure 8 below.  After opening Resource Picker, select formTitleBorderBrush.

    Figure 8 Applying Resource

  • Using the Document Outline, select the TextBlock
  • Using the Properties Window set the following properties
    • Text to Customer
    • VerticalAlignment to Center
    • FontSize to 18
    • FontWeight to Bold
    • Foreground to formTitleForegroundBrush
      • Use Resource Picker
  • Select the Grid
  • Hover cursor over the left Grid rail for the top row. Set top row to Auto sizing as in Figure 9 below
  • The bottom image in Figure 9 shows the completed form title

Figure 9 Auto Sizing Row

Adding the ComboBox Used for Record Selection 

Step One

  • Select the root Grid by clicking inside the Window
  • Create a new Grid Row that takes up about 25% of the Window
    • Click the Grid rail on the left to create a new row
  • Draw a StackPanel inside the new row
  • Add a TextBlock to the StackPanel by double clicking the TextBlock icon in the Toolbox
  • Add a ComboBox to the StackPanel by double clicking the ComboBox icon in the Toolbox
  • Form should now look like Figure 10 below

Figure 10 StackPanel

Step Two

  • Select the StackPanel
  • Right click on the StackPanel, choose Reset Layout, All
  • Using the Properties Window set the following properties:
    • Margin to 11
    • Orientation to Horizontal
  • Multi-select the TextBlock and ComboBox
  • Right click on the TextBlock and choose Reset Layout, All
  • Using the Properties Window set the following property:
    • VerticalAlignment to Center
  • Form should now look like Figure 11 below

    Figure 11 StackPanel

Step Three

  • Select the TextBlock
  • Using the Properties Window set the Text property to Select Customer
  • Select the ComboBox
  • Using the Properties Window set the following properties:
    • Margin to 7, 0
    • Width to 175
  • Form should now look like Figure 12 below

    Figure 12 Record Selector Completed

Step Four

From the Data menu, select Show Data Sources.

Figure 13 Data Menu

Figure 14 Data Sources Window

Important
Before clicking the Add New Data Source link, you must have built your solution.  The Data Sources Window uses reflection to discover types in your solution.  If the type has not been built yet, it will not appear in the Data Sources Window.
  • Add a new Data Source by clicking on the “Add New Data Source…” link pictured in Figure 14 above
  • When the Data Source Configuration Wizard is displayed select the Object icon and click the Next button

Figure 15 Select Data Objects

  • Drill down to the Customer object and select it, then press the Finish button
  • Figure 16 below shows the newly created Object Data Source

Figure 16 New Data Source

Step Five

The ComboBox will provide Customer selection. To wire up the ComboBox drag the Customer object and drop it on the ComboBox as pictured in Figure 17.

Figure 17 Binding ComboBox

  • Select the ComboBox
  • Using the Properties Window set the DisplayMemberPath to Name
  • Run application. You should be able to view data as pictured in Figure 18.

Figure 18 Run Application

Note
As part of the Solution Starter, the ApplicationMainWindow Loaded event has code that populates the CollectionViewSource for the application. This is code that developers would normally have to write as the Object Source drag and drop from the Data Sources Window does not add code to your projects.

Adding the Details Form 

The details form in this application plays the role of the Master in our Master-Details application.

Step One

Customize the Customer object output.

Figure 19 Change Layout Type

  • Change the Customer object layout to Details as pictured in Figure 19 above

Figure 20 Change CustomerID Control

  • Change the CustomerID field to use the Label control when rendered as pictured in Figure 20 above

Step Two

Figure 21 Adding New Row

  • Select the Grid and add a new row as pictured in Figure 21 above.

Figure 22 Details Form Generation

  • Drag and drop the Customer object to the Grid Row below the ComboBox
  • With the Details Grid selected, use the Properties Window and reset the following properties:
    • Height
    • Width
  • Using the Properties Window set the following properties:
    • VerticalAlignment to Top
    • Margin to 11
  • Select the outer Grid and change the Details Form row to use Auto sizing
  • The application should now look like Figure 23 below
  • Run the application and select different Customers

Figure 23 Details Form Completed

Adding the DataGrid 

Step One

Customize the Addresses object output.

  • Expand the Address node
  • Set the CustomerID field control to None

Step Two

Figure 24 Add Grid to Bottom Row

  • Add a Grid control to the bottom row
  • With Grid selected, right click, select Reset Layout, All
  • Using the Properties Window set the following property:
    • Margin to 11

Step Three

Figure 25 Drag and Drop DataGrid

  • Drag and drop the Addresses object from the Data Sources Window to the Grid control added in Step Two above
  • With DataGrid selected, right click, select Reset Layout, All
  • The DataGrid should now look like Figure 26 below

 

DataGridResized

Figure 26 Data Grid Resized

Step Four

Edit DataGrid columns using the XAML Editor.

Figure 27 DataGrid Columns

  • Insert a DataGridComboBoxColumn as pictured in Figure 27 above by copying the below XAML:

<DataGridComboBoxColumn SelectedValueBinding=”{Binding Path=AddressType.AddressTypeId, Mode=TwoWay}” ItemsSource=”{x:Static local:Data.AddressTypes}” DisplayMemberPath=”Name” Header=”Address Type” SelectedValuePath=”AddressTypeId” />

  • Cut and Paste the Street column so that it is above the City column as pictured in Figure 27 above.
  • Run you application
    • You can add, edit and delete rows in the DataGrid
    • Notice that the ComboBox in the DataGrid provides selection for the Address, AddressType.
Note
See How does it Work section below for an explanation of the DataGrid ComboBox.

How does it Work? 

The CollectionViewSource is a powerful class that provides a wrapper around a data source, adding sorting, grouping and filtering functionality without changing the source data.

The CollectionViewSource is a proxy class to the underlying CollectionView that provides navigation of collection items.

Information
MSDN CollectionViewSource documentation can be viewed here: http://msdn.microsoft.com/en-us/library/system.windows.data.collectionviewsource.aspx

Figure 28 Data Object Relationships

  • The Data.Customers ObservableCollection is the source for the CustomerViewSource. This data is wired up in the ApplicationMainWindow.Loaded event.
  • When the ComboBox selection changes it sets the CurrentItem on the underlying CollectionView.
  • The Details Form is bound to the CurrentItem. When selection changes, the Details Form DataContext changes and the selected Customer is displayed.
  • The CustomerAddressesViewSource is bound to the CurrentItem (current Customer) Addresses property.
  • The DataGrid is bound to the CustomerAddressesViewSource and displays all items in this collection.

DataGrid ComboBox

The DataGrid ComboBox displays the AddressType.Name for the Address and provides selection of an AddressType.

Figure 29 DataGrid ComboBox

  • SelectedValueBinding property gets and sets the AddressTypeId for the Address in the row
  • ItemsSource is set to the static (Shared) property AddressTypes exposed by the Data class. AddressTypes is a collection of AddressType.
  • DisplayMemberPath is the Name property of the AddressType
  • Header is the column header displayed in the DataGrid
  • SelectedValuePath is the AddressTypeId of the AddressType
Information
MSDN DataGridComboBoxColumn documentation can be viewed here:http://msdn.microsoft.com/en-us/library/system.windows.controls.datagridcomboboxcolumn(VS.100).aspx

Comments 

Microsoft values your opinion about our products and documentation. In addition to your general feedback it is very helpful to understand:

  • How the above feature enables your workflow
  • What is missing from the above feature that would be helpful to you

Thank you for your feedback and have a great day,

Autor: Karl Shifflett

Fonte: http://blogs.msdn.com/b/wpfsldesigner/archive/2010/01/19/create-wpf-master-detail-ui-using-data-sources-window-object-datasource.aspx
Visual Studio Cider Team

Creating an ASP.NET report using Visual Studio 2010 – Part 3

We continue building our report in this three part series.

Creating an ASP.NET report using Visual Studio 2010 – Part 1

Creating an ASP.NET report using Visual Studio 2010 – Part 2

Adding the ReportViewer control and filter drop downs.Open the source code for index.aspx and add a ScriptManager control. This control is required for the ReportViewer control. Add a DropDownList for the categories and suppliers. Add the ReportViewer control. The markup after these steps is shown below.

<div>

    <asp:ScriptManager ID="smScriptManager" runat="server">

    </asp:ScriptManager>

    <div id="searchFilter">

        Filter by: Category :

        <asp:DropDownList ID="ddlCategories" runat="server" />

        and Supplier :

        <asp:DropDownList ID="ddlSuppliers" runat="server" />

    </div>

    <rsweb:ReportViewer ID="rvProducts" runat="server">

    </rsweb:ReportViewer>

</div>

 

The design view for index.aspx is shown below. The dropdowns will display the categories and suppliers in the database. The report will be filtered by the selections in the dropdowns. You will see how to do this in the next steps.
image 
Attaching the RDLC to the ReportViewer control by clicking on the top right of the control, going to Report Viewer tasks and selecting Products.rdlc.  
image
Resize the ReportViewer control by dragging at the bottom right corner. I set mine to 800px x 500px. You can set this value in source view also.

image

Defining the data sources.
We will now define the Data Source used to populate the report. Go back to the “ReportViewer Tasks” and select “Choose Data Sources”
image
Select a “New data source..”
image

Select “Object” and name your Data Source ID “odsProducts”

image 
In the next screen, choose “ProductRepository” as your business object.
image
Choose “GetProductsProjected” in the next screen.

image 
The method requires a SupplierID and CategoryID. We will have the data source use the selected values of the drop down lists we defined earlier. Set the parameter source to be of type “Control” and set the ControlIDs to be ddlSuppliers and ddlCategories respectively. Your screen will look like this:
image
We are now going to define the data source for our drop downs. Select the ddlCategory drop down and pick “Choose Data Source”.

image
Pick “Object” and give it an id “odsCategories”
image 
In the next screen, choose “ProductRepository”
image
Select the GetCategories() method in the next screen.
image 
Select “CategoryName” and “CategoryID” in the next screen. We are done defining the data source for the Category drop down.
image
Perform the same steps for the Suppliers drop down.

image
image
image 
Select each dropdown and set the AppendDataBoundItems to true and AutoPostback to true.
image   
The AppendDataBoundItems is needed because we are going to insert an “All“ list item with a value of empty. This will be the first item in each drop down list. Go to each drop down and add this list item markup as shown below.
image

Double click on each drop down in the designer and add the following code in the code behind. This along with the “Autopostback= true” attribute refreshes the report anytime the selection in the drop down is changed.

protected void ddlCategories_SelectedIndexChanged(object sender, EventArgs e)

{

    rvProducts.LocalReport.Refresh();

}

 

protected void ddlSuppliers_SelectedIndexChanged(object sender, EventArgs e)

{

    rvProducts.LocalReport.Refresh();

}

Compile your report and run the page. You should see the report rendered. Note that the tool bar in the ReportViewer control gives you a couple of options including the ability to export the data to Excel, PDF or word.

 image

Conclusion

Through this three part series, we did the following:

  • Created a data layer for use by our RDLC.
  • Created an RDLC using the report wizard and define a dataset for the report.
  • Used the report design surface to design our report including adding a chart.
  • Used the ReportViewer control to attach the RDLC.
  • Connected our ReportWiewer to a data source and take parameter values from the drop downlists.
  • Used AutoPostBack to refresh the reports when the dropdown selection was changed.

RDLCs allow you to create interactive reports including drill downs and grouping. For even more advanced reports you can use Microsoft® SQL Server™ Reporting Services with RDLs. With RDLs, the report is rendered on the report server instead of the web server. Another nice thing about RDLs is that you can define a parameter list for the report and it gets rendered automatically for you. RDLCs and RDLs both have their advantages and its best to compare them and choose the right one for your requirements.

Creating an ASP.NET report using Visual Studio 2010 – Part 2

We continue building our report in this three part series.

Creating the Client Report Definition file (RDLC)image 
Right click on the RDLC folder, select “Add new item..” and add an “RDLC” name of “Products”. We will use the “Report Wizard” to walk us through the steps of creating the RDLC.
image 
In the next dialog, give the dataset a name called “ProductDataSet”. Change the data source to “NorthwindReports.DAL” and select “ProductRepository(GetProductsProjected)”.

The “Data Source” may show up empty. To get it populated, make sure your project is compiled and there is an index.aspx file in the root folder. This may be a bug.
 
The fields that are returned from the method are shown on the right. Click next.
image 
Drag and drop the ProductName, CategoryName, UnitPrice and Discontinued into the Values container. Note that you can create much more complex grouping using this UI. Click Next.

 

image 
Most of the selections on this screen are grayed out because we did not choose a grouping in the previous screen. Click next.
image
Choose a style for your report. Click next.
image
The report graphic design surface is now visible. Right click on the report and add a page header and page footer.
image
With the report design surface active, drag and drop a TextBox from the tool box to the page header. Drag one more textbox to the page header. We will use the text boxes to add some header text as shown in the next figure.

image
You can change the font size and other properties of the textboxes using the formatting tool bar (marked in red). You can also resize the columns by moving your cursor in between columns and dragging.
image

Adding Expressions

Add two more text boxes to the page footer. We will use these to add the time the report was generated and page numbers. Right click on the first textbox in the page footer and select “Expression”.
image
Add the following expression for the print date (note the = sign at the left of the expression in the dialog below)
image

"© Northwind Traders " & Format(Now(),"MM/dd/yyyy hh:mm tt")

Right click on the second text box and add the following for the page count.

 
Globals.PageNumber & " of " & Globals.TotalPages

Formatting the page footer is complete.
 
We are now going to format the “Unit Price” column so it displays the number in currency format.  Right click on the [UnitPrice] column (not header) and select “Text Box Properties..”

image
Under “Number”, select “Currency”. Hit OK.
image

Adding a chart

With the design surface active, go to the toolbox and drag and drop a chart control. You will need to move the product list table down first to make space for the chart contorl. The document can also be resized by dragging on the corner or at the page header/footer separator.

image
In the next dialog, pick the first chart type. This can be changed later if needed. Click OK. The chart gets added to the design surface.
image 
Click on the blue bars in the chart (not legend). This will bring up drop locations for dropping the fields. Drag and drop the UnitPrice and CategoryName into the top (y axis) and bottom (x axis) as shown below. This will give us the total unit prices for a given category. That is the best I could come up with as far as what report to render, sorry 🙂 Delete the legend area to get more screen estate.
image
Resize the chart to your liking. Change the header, x axis and y axis text by double clicking on those areas.

image
We made it this far. Let’s impress the client by adding a gradient to the bar graph 🙂 Right click on the blue bar and select “Series properties”.
image

Under “Fill”, add a color and secondary color and select the Gradient style.
image

We are done designing our report. In the next section you will see how to add the report to the report viewer control, bind to the data and make it refresh when the filter criteria are changed.

Creating an ASP.NET report using Visual Studio 2010 – Part 1

Creating an ASP.NET report using Visual Studio 2010 – Part 2

Creating an ASP.NET report using Visual Studio 2010 – Part 3

Add a folder called “RDLC”. This will hold our RDLC report.

Tutorial 1: Introdução ao SketchFlow

Para prototipação de projetos de TI o SketchFlow da Microsoft é uma excelente ferramenta.

Um recurso bem interessante é a publicação do protótipo em ambiente web e a coleta de feedback. O cliente pode navegar pelas páginas do protótipo e entrar com seus comentários. Os comentários podem ser exportados para um arquivo de feedback e enviados para a área envolvida pelo desenvolvimento do projeto.

A DANRESA Consultoria de Informatica utiliza esta ferramenta em seus projetos com clientes. Os protótipos ajudam na visualização de telas, de processos, e de fluxos de trabalhos tornando tudo menos abstrato para os clientes. Na hora de por a mão na massa não há dúvidas nem para o cliente, nem para a DANRESA dos trabalhos a serem desenvolvidos, melhorando a comunicação e as interações a cada etapa do projeto.

Abaixo segue um pequeno tutorial sobre a ferramenta e alguns links interessantes.

 SketchFlow é uma ferramenta de prototipagem presente no Expression Blend. Esta ferramenta é muito boa para criar protótipos de aplicações para mostrar aos compradores da aplicação. Assim evita-se muito tempo perdido ao alterar constantemente uma aplicação pois podemos, a partir de um sketch book, incoporar acções e eventos. Ou seja, temos uma aplicação completamente funcional mas com o aspecto de um livro de rascunhos sendo que esta aplicação é facilmente modificável.

Neste primeiro tutorial não vamos avançar muito nas capacidades do SktechFlow. Vamos criar uma aplicação muito simples em que o utilizador vai ter uma página para fazer o login. Caso falhe será levado para um ecrã vermelho e no caso positivo será levado para um ecrã verde. 

Para criar um projecto SketchFlow basta escolher criar um novo projecto e depois escolher Silverlight 3 SketchFlow Project ou WPF SketchFlow Project dependendo do tipo de projecto que pretenda. No nosso caso pretendemos criar um projecto de SketchFlow para Silverlight 3.

Após a criação do projecto aparece-nos o nosso workspace. Como podemos ver do lado esquerdo temos o nosso projecto, os “assets” e os estados. Na tab de projectos temos todos os ficheiros que constituem o nosso projecto recentemente criado. Na tab “assets” temos todos os elementos que podemos inserir no nosso projecto, entre os quais controlos, ecrãs, estilos, comportamentos, efeitos, etc. De todos estes só vamos abordar os controlos neste primeiro tutorial.

Um projecto de SketchFlow permite-nos inserir controlos normais mas uma das coisas que mais me chamou a atenção é o facto de termos controlos do tipo esboço. Ou seja, controlos em que o template faz com que estes pareçam desenhados com lápis. Para aceder a estes controlos basta aceder à categoria “SketchStyles” como está na imagem em baixo.

Outra coisa que este SketchFlow traz é o mapa de SketchFlow. Aqui podemos criar muito facilmente transições entre os vários ecrãs. Mas iremos abordar com mais profundidade este tema mais à frente neste mesmo tutorial. 

Agora que já sabemos onde estão os nossos controlos vamos criar um simples formulário onde o utilizador irá preencher o seu nome de utilizador e password e depois carrega num botão para proceder à validação. De notar que neste tutorial não vamos tratar da parte de comportamentos. Será um tema para um tutorial mais avançado. 

O resultado final do formulário é apresentado na imagem em baixo. 

Agora que já temos o nosso formulário criado temos que criar os ecrãs seguintes e as respectivas transições. Para isso vamos utilizar o mapa. 

Ao passar o cursor do rato por cima do “Screen 1” (o nosso ecrã principal) aparecem-nos várias opções: Criar um ecrã ligado, ligar a um ecrã existente, criar e inserir uma componente de ecrã e alterar a tag visual. Se decidirmos criar um ecrã ligado vai ser criado um novo ecrã ligado a este. Se decidirmos ligar a um ecrã existente, este irá ficar ligado ao outro ecrã que escolhermos. A terceira opção permite-nos ter elementos que são comuns a todos os ecrãs (ex: Logótipo da empresa). E a última opção permite-nos alterar a cor do objecto para ser assim mais fácil identificar que tipo de objecto é. 

No nosso caso, como é possível ver na imagem em baixo, criámos 3 ecrãs. O “Screen 1” que é o nosso ecrã principal onde está o formulário, o “Sucesso” caso as credenciais estejam correctas e “Falha” caso a password ou nome de utilizador estejam errados. De reparar que alterámos as cores para melhor compreender o diagrama. Neste caso não era muito dificil de perceber mas em esquemas mais complexas torna-se mais complicado. 

De reparar, na imagem acima, que do “Screen 1” para o ecrã “Falha” temos uma seta para a frente e outra para trás. Isto porque no caso de existir um erro na introdução das credenciais queremos dar a possibilidade ao utilizador de voltar a tentar como podemos ver no ecrã em baixo. Para o caso de sucesso temos um ecrã bastante semelhante ao apresentado em baixo mas sem nenhum botão e com a cor verde. 

Agora já temos os ecrãs. Mas então e como navegamos entre eles. Muito facilmente!!!…como podemos ver em baixo. Basta pressionar sobre o objecto com o botão direito do rato e escolher o ecrã para o qual pretendemos ir. 

Agora já temos o nosso projecto terminado. Vamos testá-lo. Para isso basta pressionar F5 para compilar e correr o mesmo utilizando o SketchFlow Player. Tal como podemos ver no ecrã apresentado em baixo temos assim acesso a todos os ecrãs que estão ligados ao ecrã principal. É portanto muito fácil navegar entre os ecrãs. 

Por exemplo, ao navegar para o ecrã “Falha”, tal como podemos ver em baixo, temos o ecrã vermelho com o botão que nos permite navegar outra vez para o inicio. 

O objectivo deste post está concluido. De referir que o SketchFlow é uma ferramenta com muitas capacidades e não abordámos quase nenhuma neste post. Ficam para os próximos tutoriais. 😉 

Fonte do artigo: http://gozoomin.com/blogs/tbarbosa/archive/2009/10/03/tutorial-1-introdu-231-227-o-ao-sketchflow.aspx

Para assistir à vídeos tutoriais sobre a ferramenta acesse: http://expression.microsoft.com/en-us/ee426886.aspx

Stay tuned!!