Home » 2011 » November

Monthly Archives: November 2011

Call a JavaScript Function After an ASP.NET Save Event

Why/How

It can be useful to be able to call a JavaScript function after an ASP.NET event has completed, but it is not immediately intuitive how this can be done.

Adding an onClientClick event to an ASP.NET button control will execute the JavaScript call before the ASP.NET server side code executes, so an alternate solution is required.

For example today I was working on a WebForms page that has a Gridview presenting data, and that displays a detailed form page for each row in the GridView in an IFrame when one of the GridView rows is clicked. I use a FormView to handle the detailed form page information.

After editing the data contained in the detailed form page, a user can click the save button at which point the FormView’s ASP.NET Update event is triggered, and then subsequently the button’s click event fires.

Here is an example of what the page looks like, with the Gridview at the top and a detailed forms page contained in an Iframe below: (more…)

About these ads

AutoGenerate a Form Page Step-by-Step Without a Single Line of Code – ASP.NET WebForms in Visual Studio 2010:

Overview:

When working with ASP.NET Webforms the ability to quickly generate working forms that are bound to your datasource can be a huge advantage.

Earlier I was creating a Webform in Visual Studio 2010, and as part of the process I dragged a SQLDataSource object onto my page, hooked it up to a stored procedure I had written, and then dragged a FormView control onto the page and associated the FormView with my SQLDataSource.

The great thing is that I was able to simply click an option on my Form Designer control that populated the entire form for me. In Visual Studio it’s just that simple!

I then just had to add my own styling for the page and convert some of my fields to editable textboxes and dropdown lists. In general this is incredibly fast and simple and allows you to add content to the Web quickly.

I will go step by step through setting up a simple ASP.NET WebForms site and populating a form from a datasource (in this case a MS SQL Server Stored Procedure) without writing a single line of code.

Step by Step; Here’s How:

(more…)

VB Data Types VB6/VB.net – Comparison Chart

Recently I was looking into some old VB6 code and for my own reference decided I’d put together a simple summary of how VB6 data types map to .NET data types.

This is nothing new, but I thought it would be handy to have a quick comparison chart available. I obtained the information for this chart directly from the MSDN VB6 and MSDN VB.NET documentation pages (see below for the reference links).

Here is the summary: (more…)

SQL Server: Delete Duplicate Records Except the First Duplicate Record

Problem:

I encountered an interesting problem today. I had a SQL Server table with many records in it that I needed to clean up. Specifically, I needed to find all duplicate records in the table, but keep the first of each of the duplicate records.

The table also contained several rows of detail information that was different for each entry, but I only wanted to keep whatever detail information that the first of each of the duplicate records contained.

Solution:

(more…)

ASP.NET GridView RowUpdating Event Handler – Programmatically Reference Controls and set SqlDataSource UpdateParameters

Introduction:

Visual Studio allows developers to quickly put together a WebForms page simply using drag and drop options from the Visual Studio editor. Binding form controls is mostly a simple matter of attaching a DataSource and setting your controls to reference the correct field in the DataSource.

Binding a GridView control can sometimes get tricky when using the VisualStudio editor, especially when working with DropDownList controls within the grid.

Today I was working on getting a row of the GridView control to save the contents of a DropDownList, and needed to add some custom code to set values passed to the SqlDataSource control on the update event.

Solution:

(more…)

CSS3 Table Border Rounding in Older Versions of the Major Browsers

Introduction:

In the past while I have been playing with CSS3 markup to round my HTML table borders.

The latest versions of the major browsers now support CSS3 table border rounding using standardized CSS3 property tags. This means that IE9+, Firefox8+, Chrome5+, Opera10.5+, Safari5+ all support the border-radius: Npx property style.

However older versions of the major browsers each used somewhat different CSS to support rounding of table borders. Here is a result of my investigations.

Overview:

Below is a table of the CSS properties that earlier versions of the major browsers required to support HTML table border rounding. (more…)

CSS3 Table Border Rounding for Modern Browsers (IE9+, Firefox, Chrome5+)

Background:

Lately I have been playing around with HTML5 and CSS3 while building a Web Site UI for a corporate Intranet. I am guaranteed that users will be using IE, so I am happily able to tailor my code directly for IE 9.

The caveat to using CSS3 rounded borders in IE is that they are only supported in IE 9+. IE 8 and earlier browsers will not accept the style and the borders will appear square without workarounds.

How to Round your Table Borders (in IE):

It’s great how one can now round borders on tables with a simple CSS property.

For example to add a slight rounding effect to the top left and right borders of your table you can use the following style: (more…)

VB.NET Type Conversion (Casting) Overview

VB.NET supports several type conversion functions. Widening conversions are handled by the compiler and don’t need to be explicitly written, but narrowing conversions require use of VB.NET’s type conversion functions.

The three type conversion functions are:

  • DirectCast
  • CType (and CInt, CStr,…Cxxx)
  • TryCast

The compiler may not report an error if you code a narrowing conversion by accident. This is because Microsoft set Option Strict to be OFF for VB.NET projects (compared with C# projects where it is on). I think this was done to make upgrades from VB 6 easier to do since in VB 6 there was no Option Strict statement.

(more…)

Follow

Get every new post delivered to your Inbox.

Join 1,375 other followers