Tag Archive for 'asp.net'

Reporting Services – how to change font style in the toolbar of ReportViewer?

I created a report with SQL Server Reporting Services. It displayed some data and the toolbar with list of checkboxes that defined which columns should be displayed on the report (see the screenshot below). The problem was the font on the toolbar didn’t match the font on the report, i.e. it was huge in comparison to the report. In short it needed resizing…

toolbar 350x65 Reporting Services   how to change font style in the toolbar of ReportViewer?

Continue reading ‘Reporting Services – how to change font style in the toolbar of ReportViewer?’

Problems with UpdatePanel on SharePoint

If you want to add some AJAX flavour to your ASPX pages running on SharePoint you need to perform a few actions:

  • install ASP.NET AJAX on servers in your farm
  • extend SharePoint web.config file with Microsoft ASP.NET AJAX
  • add ScriptManager either in the master page you’re using (prefferable) or in all pages that employ AJAX

The above listed steps are well described in the following article: Integrating ASP.NET AJAX with SharePoint.

However, at the end of the day you may (and probably will) end up with some problems during development. In short, not all works as it’s supposed to and how it does in a regular web project. One of the issues I had recently was UpdatePanel which made my page not working after a while.

Basically, I had an ASPX with some controls that had event handlers assosiated with them (e.g. buttons with onclick’s). There too was an UpdatePanel which was triggered by an event, let’s say “Click” perfomed on a button. This event made the UpdatePanel reload, BUT ONLY FOR THE FIRST TIME. Once reloaded, none of the handlers assosiated with any of the controls on the page worked.

I did a lot of googling but finding the answer was not that easy. Finally my friend gave me the link to this article. The solution is described in section “Using UpdatePanels within SharePoint”. The author suggests to add this JavaScript code to the page:

<script type="text/javascript">
    _spOriginalFormAction = document.forms[0].action;
    _spSuppressFormOnSubmitWrapper=true;
</script>

Parser Error Message: This page allows a limit of 200 controls, and that limit has been exceeded.

By default, web.config of SharePoint (should be there: C:\Inetpub\wwwroot\wss\VirtualDirectories\80) defines the maximum number of controls as 200. Should you define more on a page you’ll probably get an error similar to this:

spscreen 350x140 Parser Error Message: This page allows a limit of 200 controls, and that limit has been exceeded.

Solution

In order to fix it, edit this web.config. Find configurationSharePoint\SafeMode tag and change the MaxControls attribute to a bigger number. Once you do this, reload the page. It should help.

The feature name XXX already exists in SharePoint. You need to rename the feature before solution deployment can succeed.

From time to time when I try to deploy a SharePoint project from Visual Studio 2005 I’m getting this error:

The feature name XXX* already exists in SharePoint. You need to rename the feature before solution deployment can succeed.

Solution
Whenever I get this (annoying) error I go to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\ and remove the directory named XXX*. Sometimes then I need to restart Visual Studio or even log off and on again (on my Windows account).

17/102008
Sometimes restarting Visual Studio does the job.

* is the name of the module that should be deployed

 The feature name XXX already exists in SharePoint. You need to rename the feature before solution deployment can succeed.

ASPX running on Sharepoint – display stack trace

Should you need to see the stack trace when an error on an APSX page hosted by Sharepoint occurs do the following:

  • SharePoint\SafeMode: AllowPageLevelTrace="true" and CallStack="true"
  • system.web\customErrors:mode="Off" or mode="RemoteOnly"

Yet the standard error page usually does not tell aything that can suggest the reason for the error…

Security in accessing reports on Report Server

Once you deploy reports on to Report Server they can be accessed from any Web application with an established URL. However, I see a scenario when one wants to prevent some users from accessing reports (e.g. a user should be able to view reports presenting only their personal information).

The way around this is to view reports on an aspx page by employing ReportViewer control, which makes it possible to view reports hosted locally or deployed on (in particular remote) ReportServer. I’ve chosen the former approach.

In order to use ReportViewer with reports hosted locally, you need to:

  • change the extension of the report files from RDL to RDLC
  • configure ReportViewer control so it is associated with an appropriate RDLC file and DataSource (you will need to configure it by providing the connection details, specifying the SQL query or stored procedure that will retrieve the data)
  • in code behind for that aspx page (in Page_Load method) you can add some logics that checks if the currently logged user can access the report; if not, you can just throw an Exception
  • if you want to pass parameters to the ReportViewer, you will have to add a few lines to the above mentioned method:
    ReportParameter p = new ReportParameter(PARAM_NAME, PARAM_VALUE);
    reportViewer.LocalReport.SetParameters(new ReportParameter[] { p });
 Security in accessing reports on Report Server

ASP.NET AJAX In Action

If you’re about to start playing with AJAX in ASP.NET it’s a good idea to read this book: ASP.NET AJAX In Action by Alessandro Gallo, David Barkol, Rama Krishna Vavilala (see on amazon).

It very well describes basics of AJAX and shows basic and more advanced techniques of applying it in ASP.NET. There are exaplanations of Microsoft Ajax Library, UpdatePanel, ASP.NET AJAX client components, bulding AJAX-enabled controls, and much, much more. All well written and supported with extensive examples.

AJAX Control Toolkit – Could not load file or assembly vjslib

I wanted to play around with ASP.NET AJAX Control Toolkit. There are a few steps to do before you can start using this tool. Among others, you need to build the Visual Studio Solution provided in the downloaded zip file.

When I tried to build the solution I got this error:

Error 1 Could not load file or assembly ‘vjslib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The system cannot find the file specified. C:\Program Files\Microsoft ASP.NET\Ajax Control Toolkit\TemplateVSI\TemplateVSI.csproj 60 5 TemplateVSI

Solution

This is what AJAX Control Toolkit documentation says:

The TemplateVSI project has a dependency on vjslib.dll which is a part of the Visual J# Redistributable…

The above mentioned package can be found there. Installing it solved this problem, at least on my computer.

ASP.NET powered with AJAX

For those who develop web applications in ASP.NET and want to learn how to include AJAX I recommend a series of video tutorial on ASP.NET AJAX.

The series is created (from time to time new videos are added) by Joe Stagner and others from the Microsoft product team. It teaches the basic tricks and explanations of how things should be done.

Refreshing C# and ASP.NET skills

As a matter of fact I’ve been learning Java (for SCJP) and Microsoft .NET (because of project change) recently.

This week I attended two crash courses:

Those courses were fine; I refreshed a lot and learned some new stuff as well. Now it’s time to play around with this knowledge in real world icon wink Refreshing C# and ASP.NET skills