Setting Parameters in Crystal Reports .NET

I see this question quite often in the Crystal Reports forum at ASP.NET.  My advice is always to download the web samples at:


Visual Basic .NET Web Samples


C# .NET Web Sample Applications


Then, follow the Readme file to install the “Discrete Parameters” example.  This has been my guide, and it works great.


Additional help and tutorials are in the CR SDK:


Crystal Reports .NET SDK – Additional Conceptual Documentation and Tutorials



This file contains additional conceptual information and tutorials for using Crystal Reports in Visual Studio .NET (including a developer reference). This documentation applies to Crystal Reports 9 & 10 and Crystal Reports for Visual Studio .NET 2002 & 2003. Sample applications built using these tutorials are available for download (cr_net_sdk_tutorial_samples_en.zip).


Crystal Reports .NET SDK – Sample Applications from Tutorials



This file contains C# and VB .NET Windows and web sample applications. These samples were built using the tutorials provided in the ‘Crystal Reports .NET SDK – Additional Documentation and Tutorials’ (cr_net_sdk_additional_en.zip). These sample applications applies to: Crystal Reports 9 & 10 and Crystal Reports for Visual Studio .NET 2002 & 2003.  


A number of methods out there use the CrystalReportViewer control to set parameters.  That’s great unless you need to export your report to PDF (or XLS or RTF).  This is a code snippet I use, which sets parameter values directly on the Report Document object:



  rptCount = New ReportDocument
  rptCount.Load(Server.MapPath(“reportname.rpt”))

  ”Get the collection of parameters from the report
  crParameterFieldDefinitions = rptCount.DataDefinition.ParameterFields
  ”Access the specified parameter from the collection
  crParameter1 = crParameterFieldDefinitions.Item(“Param1”)
  crParameter2 = crParameterFieldDefinitions.Item(“Param2″)


  ”Get the current values from the parameter field.  At this point
  ”there are zero values set.
  crParameter1Values = crParameter1.CurrentValues
  crParameter2Values = crParameter2.CurrentValues


  ”Set the current values for the parameter field
  crDiscrete1Value = New ParameterDiscreteValue
  crDiscrete1Value.Value = Request.Form(“param1value“)


  crDiscrete2Value = New ParameterDiscreteValue
  crDiscrete2Value.Value = Request.Form(“param2value“)


  ”Add the first current value for the parameter field
  crParameter1Values.Add(crDiscrete1Value)
  crParameter2Values.Add(crDiscrete2Value)


  ”All current parameter values must be applied for the parameter field.
  crParameter1.ApplyCurrentValues(crParameter1Values)
  crParameter2.ApplyCurrentValues(crParameter2Values)



Once you get used to working with parameters, you can “automagically” display them on your web pages.  This series of articles shows you how to get a list of parameters from your report file, and display them on your web form, where you can prompt for inputs:


Automagically displaying a Crystal Reports Parameters – Part I
Automagically displaying a Crystal Reports Parameters – Part II
Automagically displaying a Crystal Reports Parameters – Part III


If you’re new to Crystal Reports .NET, get this book:


Crystal Reports .NET Programming


It is both an introduction to Crystal Reports .NET, as well as a object model programming guide/reference.  Examples are in both VB.NET and C#.


Journal Pro – Journal App for Pocket PC 2003

I needed something better than the Notes that came with my Pocket Outlook 2003, so I tried several journal applications.  This was my favorite!  I use both the desktop and pocket versions.  Great for keeping track of what you do for what client, phone conversations, and notes for the next ASP Alliance article!  This is not a plug-in for Pocket Outlook, but it can integrate with the Task and e-mail functions.


Some of the best features include having multiple journal files, with multiple journals in each file, password protection, easy navigation and time stamping.  I use this on a Dell Axim X5 running Windows Mobile 2003.


Journal Pro w/ Desktop Bundle! by DSRTech, Inc.



Journal Pro is the definitive application for journal/diary keeping on the Pocket PC platform! And now it’s even better than ever…


With the addition of Journal Pro Desktop Edition you’re always ready to record your thoughts whether at home, the office, or on the road. And you’ll rest easy knowing that your files will always be in sync!

Version 2.6 contains version 2.5 of the desktop application and version 2.6 of the pocket pc application.

Features Include:


  • Seamless Integration with Journal Pro Desktop Edition!
  • Voice Recording
  • File Encryption
  • Skinning of the pocket pc application
  • Lightening Fast Journal Access!
  • Password Protection
  • Categories Within Your Journal
  • Full Text Searching
  • Calendar Navigation and “Quick Nav”
  • Skip Over Days With No Entry
  • Pocket Outlook Task and Email Integration
  • Font and Color Selection
  • Text Export
  • Auto-exit after inactivity timeout
  • Purge Data When No Longer Needed
  • Completely File Based
  • Compatible with the new Pocket PC 2002 Operating System

Axim goes Artsy – Claude Monet Themes

My mother, patroness of the arts, would be so proud!


Great collections of Great Impressionist Artist Claude Monet’s works, the artistic themes for your today screen included the famous painting series:-
·Water Lily 1914
·London Parliament in Dusk 1904
·The Parc Monceau 1878
·Lilacs Overcast Weather 1872


Monet1 by Mediasofts By Paul


And another one (part of a 4-part series)


Claude Monet Today Themes Pack 3 by Natural Installer Inc.

CAPTCHA Images for your website

I have a love/hate relationship with those CAPTCHA tests on websites.  I understand why, and am fascinated at just how good the human mind is at pattern resolution.  Yet, they’re additional typing.  Anything to foil a spambot I guess.


I was looking into adding a test into a project of my own, and I came across these references.  Examples of the first article are shown beneath it.


15 Seconds : Fighting Spambots with .NET and AI



This article explains how intelligent applications from Carnegie Mellon University and Berkeley researchers counter auto registration spam programs and how to build your own using ASP.NET & XML Web services.


 


A Generic CAPTCHA Image Tester



What’s unique here is my implementation – it’s generic enough to use in a classic ASP page, or in an ASP.NET page, it does NOT require the use of Session State, and that’s what makes it more useful. The key here is that we use an aspx page to generate the image, and we simply make our image tag’s src property point to this page.


The Code Project – CAPTCHA Image – ASP.NET



This article demonstrates how to create such an image and employ it within an ASP.NET web form.


The CAPTCHA Project Website – CMU School of Computer Science


CAPTCHA.NET is the homepage of CMU’s CAPTCHA Project


Formshield is a free .NET CAPTCHA control available at http://dotnetfreak.co.uk/blog/archive/2004/11/06/166.aspx.


Many thanks to Kevin Gearing!  There are some samples as well–very cool.



FormShield started out as a simple project with just one aim – to prevent automated form submission using dynamically generated images.


Not exactly a new idea – dynamically generated images requiring the user to enter the text found on the image have been around for quite a while (see http://www.captcha.net/), preventing automated sign-ups to free e-mail services such as HotMail and Yahoo, and automated whois lookups on domain names on sites such as Network Solutions.


Whilst some code exists on Code Project (http://www.codeproject.com/aspnet/CaptchaImage.asp), there didn’t however seem to be a free, easy-to-use and customisable control for ASP.NET with full designer integration that could generate the relevant images. So, looking for an excuse to delve into GDI+, FormShield was born and my idea of a ‘simple’ control was dropped…

PanIP Patent Overturned

This has been dragging on for a couple of years, and I’m glad to see the USPTO has come to its senses somewhat.  I’m no lawyer, but I would think having your patent overturned due to “obviousness” would sort of put a damper on all those IP lawsuits you’ve been filing:


Patent Office issues initial rejection of patent claims in PanIP suit


Following a reexamination, the U.S. Patent and Trademark Office has issued an initial rejection of claims in a patent it had earlier granted to technology developer Pangea Intellectual Property on payment processing technology used at e-commerce sites. It is one of two patents held by PanIP whose validity is being challenged by a group of 15 e-retailers PanIP had in a separate action sued, claiming it was due licensing fees. PanIP has since settled with those retailers. A second patent on which the retailer group, the PanIP Group Defense Fund, also is challenging PanIP still is under review by the Patent Office.

PanIP has two months to respond to the Patent Office’s Action document, says Jonathan Hangartner of Sheppard Mullin Richter & Hampton LLP, the retailer group’s attorney, who terms the preliminary findings “a critical first step.” However, overcoming the initial findings will be “very difficult for PanIP. The Office Action is very well reasoned and strong,” he says.

Hangartner notes that nine of the 10 individual claims in the patent were rejected on the basis of “anticipation” in “prior art.” That essentially means that the Patent Office examiner determined that every element that the patent holder claimed to originate actually predated the patent and could be found in a single reference, such as an article, according to Hangartner. The remaining claim in the patent was rejected on the basis of “obviousness,” meaning that most elements of the claim existed in prior art and that the remaining elements would have been obvious to someone skilled in the art.

“The Patent Office has rejected the 10 claims that we challenged. That means that if that rejection holds throughout the process, the result will be the patent itself is invalid,” Hangartner says. The attorney representing PanIP, Kathleen Walker, said that while the action is ongoing, PanIP would have no comment. “We have 60 days to respond and we’ll make the appropriate responses,” she said.


The group of e-retailers formed a defense fund at http://www.youmaybenext.com.


Update 2005-08-19: YouMayBeNect.com has not been active for a while, apparently, and the retail group has disbanded after their victory.  No peep from PanIP yet. 

Don’t sniff browsers–sniff objects

As good as ASP.NET’s adaptive rendering is, I sometimes find myself needing to do some fairly substantial client-side scripting.  I used to sniff browsers, but that was getting tedious, and most common scripts are written upside down anyway.


The best method I’ve seen is to use ‘object sniffing’–testing browsers for support of different objects and methods.  This saves a considerable amount of time, since all browsers will fall into 3-4 categories of object support, and you don’t have to parse out a zillion different browser types and subtypes and still run the risk of excluding one that may work on your site.


My guide was http://developer.apple.com/internet/webcontent/objectdetection.html.  The article is a couple of years old, but it’s still useful to me today.



The pace of new browser releases may be slower than it was in the early days, but developers must still confront a bemusing array of browser versions and brands that support some JavaScript features but not others. To combat the problem, scripters commonly provide two or more code branches so that a browser follows an execution path containing statements that it supports. Browser sniffing — the task of inspecting navigator object properties for version information — has become largely unmanageable given the browser version permutations available today. This article presents details on an alternative solution — object detection — that frees JavaScript developers from most of this versioning mess.


I haven’t played around with custom server controls, so I don’t know how applicable this is for that purpose.

Allowing Only Numbers in ASP. NET TextBoxes – Use Regular Expression Validator!

[update 2012-07-16]

Kendo also has a numeric textbox input (both a widget and MVC extension), and Telerik has a numeric text input for ASP.NET Ajax.

[update 2011-10-07]

This continues to be a popular post, even though it was written in 2005.  If you need a solution for ASP.NET MVC, I’d suggest using a validation attribute on your model, and the Wijmo Complete Input jQuery UI widget (also available in the ASP.NET MVC Tools).

If you’re using WebForms, this method will still work, or you could look at the Wijmo-powered Input control.

[/update]

This article came up on the news today: Allowing Only Numbers in ASP.NET Textboxes.  In this article, Bipin uses a custom validator to enforce input.  I usually like Bipin’s ideas, but this one seems to be a little more difficult than it needs to be.

I think there’s a better way to do this–use a regular expression validator.  To test this, create a page, and add a textbox, regular expression validator, and a button.  For the validation expression, enter the following:

^[0-9]+$

Compile your page and test with some different inputs.

A quick explanation of the expression:

^ indicates the start of the input
[0-9] indicates a range of allowable characters.  You could do [0,1,2,3,4,5,6,7,8,9], but that’s not lazy.
+ indicates ‘match preceeding one or more times’
$ indicates the end of input

If you wanted to enforce a length of input, you could do something like:

^[0-9]{6,12}$

which would enforce a minimum of 6 characters and a max of 12.

I think regular expressions are too often overlooked, but they’re very powerful and simple once you work with them a little bit.  For a good basic overview of regular expressions, check out:

 

The Web Professional’s Handbook

 

And a more in-depth RegEx reference in:

 

Pure JavaScript: 2nd Ed. (an absolute steal if you buy it used)

 

Regular Expressions with .NET [DOWNLOAD: PDF]

Downloadable e-bok in PDF format, from Amazon.

 

Mastering Regular Expressions, Second Edition (The Owl Book)