Thursday, September 07, 2006

Photo "Slideshow" (On page refresh)

This may be a obvious thing to most people, but it solved a problem I was having. The ASP.NET AdRotator control is meant for ads, but someone suggested I use it as a way to have a new picture show on a page whenever it is reloaded or a new visitor comes to the page. It worked perfectly for what we needed to do.

Wednesday, September 06, 2006

"Octopus" Containers for Page Content

I found a really cool technique that will allow for a fully resizable content container for page content. One of the coolest features of this is that it is an easy way to make the appearance of rounded corners. Here's a link to the site at Dragon Labs.

Thursday, August 17, 2006

Sorting an ObjectDataSource with child Classes

I found a really good article that tells what needs to be done to create a custom comparer that will allow objects to be sorted. That's about all there is to it... but it's really good.
Here's the link.

Thursday, August 10, 2006

Set Page Titles Dynamically in ASP.NET

4guysfromrolla.com is where I end up much of the time after searching for how to do something in ASP. They have some really great information on that site. One item in particular that I thought was cool is thee fact that you can set the page title dynamically with information contained in the site map control. Read the article to be enlightened.

Thursday, August 03, 2006

Order items in a ListBox


I spent some time looking for a way to rearrange the items in a list box and there my very well be a better way to do this, but this is what I came up with. I took ideas from several things I found online to arrive at this solution that best fit my needs. The "up" and "down" strings are passed in by button click events. Another little note was that in order to get the arrows to show up in the buttons I had to change the font and enable unicode. I also had to copy the symbol I wanted from the character map.

Here's the code to make it all work:

private void MoveListBoxItem(string direction)
{
switch (direction)
{
case "up":
if (productSectionBindingSource.Position!=0)
{
int OriginalIndex = productSectionBindingSource.Position;
ProductSection SectionToMove = productSectionBindingSource.Current as ProductSection;
SectionToMove.DisplayOrder = OriginalIndex - 1;
productSectionBindingSource.Remove(SectionToMove);
productSectionBindingSource.Insert(OriginalIndex - 1, SectionToMove);
productSectionBindingSource.Position = OriginalIndex;
(productSectionBindingSource.Current as ProductSection).DisplayOrder = OriginalIndex;
productSectionBindingSource.Position = OriginalIndex - 1;
}
break;
case "down":
if (productSectionBindingSource.Position != productSectionListBox.Items.Count - 1)
{
int OriginalIndex = productSectionBindingSource.Position;
ProductSection SectionToMove = productSectionBindingSource.Current as ProductSection;
SectionToMove.DisplayOrder = OriginalIndex + 1;
productSectionBindingSource.Remove(SectionToMove);
productSectionBindingSource.Insert(OriginalIndex + 1, SectionToMove);
productSectionBindingSource.Position = OriginalIndex;
(productSectionBindingSource.Current as ProductSection).DisplayOrder = OriginalIndex;
productSectionBindingSource.Position = OriginalIndex + 1;
}
break;
default:
break;
}
}

Tuesday, August 01, 2006

SQL Contacts to Exchange (Outlook)

After being given the task of making one of our application databases be the source of a public folder contact list in Outlook, I came to find that the task is not as easy as it may seem. There are about a billion different ways to do it and you can see some of them here. The one that was decided to be the best for our purposes was Stephen Toub's Outlook Contact Provider. After implementing some caching on the project, it did exactly what we needed and it works great. This basically mimics a SharePoint web service and uses a custom provider to get the contacts from a database. I ran into a little trouble because of the conversion to ASP.NET 2.0 but after those issues were resolved, it worked like a charm.

Monday, July 24, 2006

Easy Page Layout Grids from Yahoo!

I found out that Yahoo! has a whole developer section with lots of great information for developers. One of my favorites is the Yahoo! UI Library: Grids CSS It allows you to use CSS to layout your page and if you ever want to change something it can be as easy as changing one character in the markup to have a new layout. You can move the sidebar from the left to the right or change the width of it, or completely remove it, for example. There's also a way to stack special grids in the main content section to allow for just about any design you could want... Check it out.

Friday, July 07, 2006

Google Finance: My Thoughts

I really like the charting features and clean look of Google Finance however the blog section of the site needs some work. I have found that the information it contains for the company I work for is irrelevant. Google simply does a blog search for the name of the company in question and displays whatever it finds.

This may be OK for large companies, but for smaller ones the blog posts it lists look as if they were created just so that they would show up in the search for the name of a particular company. It seems to me as if it's a case of unscrupulous bloggers trying to "spam" (can't think of a better word) the blog search engine.

I searched high and low for a way to ask Google to remove those irrelevant results and asked a question on the Google Groups support forum about it last month, but received no response. I think they should either improve the search to exclude more irrelevant posts, provide a way to have them removed, or provide us with the option to turn off the blog section completely... perhaps through some personal settings or a query string.

Get a connection string from web.config

I recently needed to get a connection string from my web.config file and had some trouble finding a definitive answer on how to do it when searching the web. Most of the info that I did trun up was for .NET 1 and I needed a solution for ASP.NET 2.0. I was finally able to get it working with some help and here is what needs to be done.
//Get the connection string
ConnectionStringSettings connectionString = ConfigurationManager.ConnectionStrings["myConnection"];
//Create the connection
SqlConnection connection = new SqlConnection(connectionString.ConnectionString);
Now that you have the connection you can use it however you wish.

In order for this to work I had to add the following using statement and refrence.
using System.Configuration;

Thursday, July 06, 2006

Package load failures

Today I encountered a problem where I was unable to successfully complete the SSIS Import Export Wizard and I arrived at the conclusion that it was due to a package load failure in VisualStudio. I assumed this because none of the items would appear in the toolbox for this type of project and when attempting to Reset All Settings through the Import and Export Settings Wizard I got a package load failure. I was able to resolve the problems with VS by following the steps outlined on Aaron Stebner's WebLog. This site was very helpful.

After that was done I also had to reinstall SQL Tools to have the Business Intelligence Projects be available in VS again. I was unable to do that because I still had the CTP installed and the release version would not proceed with the installation. It happened because the previous uninstaller for VS removed the entry in the Add / Remove programs window but left the actual proggram on the system. So I found a post called Cannot Install SQL Server 2005 on MSDN Forums with an answer to resolve the issue and the solution involved removing the CTP by using the Windows Installer Cleanup Utility. I was then able to continue installing the final release of SQL.

Wednesday, July 05, 2006

Trim a string after a full word

This is some code I wrote to trim a string to the last full word after 100 characters.

if (item.Copy.Length > 100)
{
//This line gets the index of the first space starting after 100 chars
//It then cuts the string at that point and adds "..."
item.Copy = item.Copy.Substring(0, item.Copy.IndexOf(" ", 100)) + "...";
}

First post

I created this blog more or less to archive things that I learn or find interesting on the net and I may want to look at again one day. I hope someone may find something I post useful as well.

-Brandon