Feeds:
Posts
Comments

Archive for the ‘ASP.Net’ Category

Currency Parsing, Regular Expressions

ASP.Net 2.0 has some very powerful client-side web page validation features, including classes that emit javascript validation code to the user’s web browser.  The CompareValidator, allows one to test whether the value entered into a text box is convertible to a given data type.  All one has to do add the CompareValidator tag to your markup,  set the properties and ASP.Net does the rest.  But don’t expect it to handle a dollar sign: use a regular expression for that!

(more…)

Read Full Post »

Keywords: Open Office, Ghostscript, Do It Yourself Convert Microsoft Word, Excel, Powerpoint to PDF

I’ve written a small program that uses Open Office to open and save different kinds of Microsoft Office files to PDF, and optionally merge them into a single output PDF file using GPL Ghostscript. I posted the code and article at the Code Project: http://www.codeproject.com/KB/java/PDFCM.aspx.

It’s a command line program, and we’re using a simplified version of it in production to do back-office conversions and merges of office files that we get from filling out forms internally and others that we get from customers. There are potentially many documents, and they can vary in size, so it is very cumbersome to cut, paste, print and scan everything to PDF (which is what our staff were doing when I started this project.)

Fortunately, it turns out that (1) one can use PRNADMIN.DLL with a Postscript Printer driver and an ActiveX IE browser to render a web page to Postscript, (2) Open Office can batch convert Microsoft Office files (and many more) to PDF, and (3) Ghostscript will merge Postscript and PDF on the command line.
(more…)

Read Full Post »

Keywords: Microsoft Printer Automation, .Net Printer Settings, COM Printer Settings

So you want to set the default printer on your windows system? Or maybe you want to install a printer on the fly, or change a printer’s settings?

Oh, and you want to do this from within a .Net program? (And I won’t even ask you “Why?” because I already know: it’s because you have a job ;-)

While I am not aware of any APIs that do this natively in the .Net world, there is a nifty DLL that you can get from Microsoft called prnadmin.dll. It may already be installed somewhere on your system, but if not, you can get it from Microsoft as part of the Windows 2000 or 2003 Server Resource Kit. This DLL exposes a number of COM APIs that do many useful things with printers and printer settings.

(Update: See my CodeProject Article about using PRNADMIN.DLL)


(more…)

Read Full Post »

Very strange. I have a few interfaces I needed to re-factor. Step 1 was supposed to be simple: rename the interfaces. I highlighted an interface name in Visual Studio, right clicked and selected rename, and waited. And waited.

And waited.

So I think, as a progress bar indicates that every file in my solution is being scanned, “Oh it’s just a first time thing, it’s building an index, right?” So after it was finished I highlighted another interface name, right clicked and selected rename, and waited. And waited.

And waited.

It takes less time to clean and re-compile my solution from scratch than it does to rename one interface, and I have many interfaces to rename. One would think that an index of tokens would be built by the compiler that could be used in a renaming operation.

One would be wrong.

Update: By the way, this is so much faster in SharpDevelop.  My memory is that it was much faster in IntelliJ (for Java) as well.  Hopefully this is fixed in VS2008.

Read Full Post »

Recently I deployed an ASP.Net web application that was designed to gather complex form data and store it in a database. The object model was large and complex enough that it couldn’t be stored in View State, given the network within our organization. So instead we stored the form data in Session state. Simple enough, server memory is comparatively cheap. During 10 months of requirements meetings however, it never came up that users might want to have multiple forms open at the same time, each looking at different instances of the business data. And this week, precisely that happened.

What does that spell? That’s right: M-A-Y-H-E-M.
(more…)

Read Full Post »

I like GridView, but using it is a sometimes like getting behind the wheel of a 747 without ever flying before.

I have a software tracking report to make that pulls data out of database using an SQLDataSource. Everything in the database is keyed on the computer name, so to make a list of installed applications across the domain, I do a GROUP BY on application name and version in the select statement. The report displays the name, version, and count in a GridView. To get the list of computers where a particular application name and version instance is installed, I query the database on GridView select. But since it’s a GROUP BY, there is no permanent primary key, and so I need to know both the application name and the version for the query.
(more…)

Read Full Post »

I submitted an article recently to The Code Project on how to use a GridView control in a Business Layer. The article and accompanying code demonstrates a way to use the GridView control with a business layer. Though I’ve been using that solution in several projects successfully for several months now, I’m still bothered by the baroqueness of it all. When I started out, I really just wanted to bolt the Grid control onto a generic list of business objects. One by one, I encountered various roadblocks. First, the elements in the list had to be Serializable, and of course in a rich domain model this means practically the whole business layer has to be declared Serializable. Then the ObjectDataSource had to get it’s data from a stateless class. Then I couldn’t use static methods in the ObjectDataSource. Etc, etc, etc.

(more…)

Read Full Post »

Older Posts »