Posts

Duplicates on postback in your ASP.net Dropdown Box

Let's say you are working on a dropdown box letting the user select a state and a county. You might want to have the county be filtered by the state, so you add an autopostback event to the state dropdown. Let's also say, however, that you are allowing the search to proceed without selecting a county, so you add <asp:listitem Text="All Counties" Value="" /> as your first item and add appendDataBoundItems="True" to your counties dropdown. Because you have now enabled autoappend, the act of changing the state will cause a postback and keep appending counties to your county dropdown box. The solution? Add EnableViewState="False" to your Counties dropdown box. Yes, this may be obvious for some, but it's an easy thing to overlook and can lead you down a rather complex road of coding around viewstate that you may not want to explore.

SSL showing non-secure in some browsers?

Image
I have had a few cases recently where a customer will complain about a specific browser giving them a non-secure connection, or mix-ed mode error on some browsers. Most commonly, older versions of IE are the culprits, but I have seen a case where Firefox 4 showed a page as non-secure while IE8 and 9, Chrome and Safari all had no issues with it. When your customers are banks, you want to make sure even their customers running obsolete IE6 and IE7 browsers see the padlock, despite the other mountain of issues involved with supporting older browsers. Any one little item can be the culprit. Some browsers don't consider certain connections to be an issue, while others do. The obvious things to check first are script source paths for js libraries, etc... Make sure those are using https. As of the time I am writing this, embedded Google maps cannot be on an SSL page. However, when all else fails and you find yourself sifting through nested js files and searching for image source paths tha...

Store ASP.net membership roles in SQL Server

Setting up ASP.net membership roles is a breeze, but if you want to use SQL server to handle the authentication you need to make a few changes. After looking up the syntax repeatedly, I decided to create a mini step by step that includes what changes need to be made in the web.config, the sql permissions and how to set up users / roles. Assumptions: You have a working Visual Studio project and a SQL server connection working. Using: Visual Studio 2008 / ASP.net 3.5 project SQL Server: 2005 Step 1 From the command line (running as administrator) From: Windows\Microsoft.NET\Framework\v2.0.50727\ aspnet_regsql.exe -E -S lrswsqlt1 -d  databasename -A all -sqlexportonly c:\membership.sql Step 2 In SQL Server Execute the SQL created in c:\membership.sql GRANT EXECUTE TO  dbuser Step 3 Modify the web.config (This assumes you already have a working sql connection string in place) Under the <machineKey... tag /> <authentication mode="Forms"> <forms cookieless="Use...

Convert a LiveCycle Form back to an Acrobat Form

Image
PDF Forms that were saved with Adobe LiveCycle cannot be programatically filled and flattened using most API's, like ActivePDF. However, you can convert your LiveCycle PDF form back into a static PDF. 1. Open the form in LiveCycle and save it as Adobe Static PDF form. (Example using Acrobat X Pro) 2. Download PDFTK  http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/ 3. Remove extra XML data with the following command line. I copied the creditApplication.pdf file to the same folder. "pdftk creditApplication.pdf output test.pdf drop_xfa" 4. Now you can open the form in Acrobat and rename the forms fields. By default, the conversion might append form[0] stuff to the field names, so I rename them. 5. Save the new PDF using "Save As". Choose "Adobe PDF Files, Optimized (*.pdf)" and in the optimizer window, make it compatible with Acrobat 4.0 and later. 6. You now have a form fillable PDF that you can use programatically and will flatten properly. [gallery ...

ASP.NET: Inserting Null DateTime values in SQL Server

A problem I run into from time to time is inserting Null values into a SQL Server DateTime field. We typically use Stored Procedures for everything and catch all statements to handle errors during insert. Usually, when you don't set a default on a control its value is Null. Likewise, if you explicitly set a control to Nothing (vb.net) It sends a Null. However, DateTime fields like to send the time with no date, which creates a non-null and invalid date for SQL server leading to an overflow exception. After a lot of frustration with setting values to nothing, DbNull, etc... I found a solution. I check to make sure it is a valid SQL date (not VB.net) by testing if it is greater than 01/01/1900 and if not, setting it to System.SqlTypes.SqlDateTime.Null. You could place this in a BLL, or directly before you pass the date in. If Not EventDate > "01/01/1900" Then EventDate = System.Data.SqlTypes.SqlDateTime.Null End If I hope this helps someone as it has become standard pra...

ASP.NET - Referencing a control inside of a user control

ASP.NET Mini Tutorial - Referencing a control inside of a user control Let's say you have a usercontrol that contains a dropdown list of states that you use across many pages. In the codebehind of the page, you will likely need to reference that dropdown list, but it's nested inside a usercontrol, so you must use the FindControl method to access it. Example: First, create a new object called ddlState and make it a dropdownlist Dim ddlState As DropDownList = StatesDropDown1.FindControl("ddlState") Now you can reference it just like it was a control on the page: txtExample.text = ddlState.SelectedValue

CompassBill has arrived

It's finally here. I have been working on CompassBill, an online billing / invoicing system for a long time. After many sleepless nights, we finally got things on track and launched it. I don't often plug my own projects, but I think this one is worth a look if you are looking for a simple invoicing system for your clients. As a web designer, I have been eating my own dog food for a couple of years now, so if you are in the design / development field you might find this is a pretty decent way to bill your clients. Read and post comments | Send to a friend