About the author

Name of author Kevin Brammer lives in Houston and spends most of his time painting, designing, and programming ASP.NET/C#.
E-mail me Send mail

Pages

Advertisements

 

Yahoo Style GridView Theme Using CSS

by Admin 9/11/2008 8:25:00 PM

Live Demo

I just added a Yahoo style GridView theme to the sandbox, which is designed to work with an out-of-the-toolbox GridView control. I wanted to experiment with sprite design, where all of the backgrounds are combined in one image and shifted using CSS. All in all, I think it works fairly well ^_^

As usual, I have tried to keep all my themes as simple as possible to implement. You can check them out here.

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

ASP.NET

Populate SubSonic DropDown with Distinct Values "System.Data.DataRowView"

by Admin 7/24/2008 8:22:00 PM

I was having a little trouble figuring out how to select only distinct values from a column and populate a dropdownlist using SubSonic and ASP.NET 2.0 C#. Here is my solution:

 

SubSonic.Query q = new SubSonic.Query("Projects");
            q.QueryType = SubSonic.QueryType.Select;
            q.DISTINCT();
            q.SelectList = "ClientName";
            q.ORDER_BY("ClientName");
 
            DropDown1.DataSource = q.ExecuteReader();
            DropDown1.DataTextField = "ClientName";
            DropDown1.DataBind();

 

If you are getting "System.Data.DataRowView" when binding the SubSonic DropDown control programmatically, be sure to check if you set the DataTextField property of the DropDown control to the correct column name.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

ASP.NET

Photo Gallery Example Using ASP.NET and Flex

by Admin 7/8/2008 1:33:00 PM

I have been dabbling with Flex recently with the intent to try and create a simple XML driven Flash photo gallery with scrolling thumbnails. I am happy with the results so far, although I plan on improving the UX, error handling, load time and adding the ability to browse several categories. Once that's done I'm considering doing the whole project again in Silverlight ^_^

Live Demo

ASP.NET Web Handler

I decided to have the list of photos for the gallery delivered as XML using a standard .NET web handler. This way I can add or delete photos in the future without having to tinker with the Flex application. Since my photos are hosted at Flickr, I chose to use the Flickr.NET API to gather information from a specific photo set on my account and let the web handler format the result as XML. I will eventually also have the web handler respond dynamically to different URL parameters in order to browse more than one photo set. There are a couple of good examples available at the FlickrNet API Library on CodePlex if you haven't used this API before. The most important thing to remember is if you are hosted on a shared server such as 1and1 (like me), you may find that you need to specify a proxy in both the <flickrNet /> and the <defaultProx /> locations in order to make any web requests outside of your host. You will also need to get you API key and secret from Flickr to add to the web.config.

web.config

Setting up flickr.dll and 1and1 proxy:

<configuration>
  <configSections>
    <section name="flickrNet" type="FlickrNet.FlickrConfigurationManager,FlickrNet" 
       allowLocation="true" />
  </configSections>
  <flickrNet apiKey="yourFlickrAPIKeyGoesHere" secret="yourSecretGoesHere" 
       cacheDisabled="true" >
    <proxy ipaddress="ntproxy.1and1.com" port="3128" />
  </flickrNet>
  <appSettings>
    <add key="UserId" value="yourFlickrUserIdGoesHere"/>
  </appSettings>
 
  <!-- rest of web.config -->
 
  <system.net>
    <defaultProxy>
      <proxy usesystemdefault="False"
       bypassonlocal="False"
       proxyaddress="http://ntproxy.1and1.com:3128"
       />
    </defaultProxy>
  </system.net>
</configuration>

Formatting the information returned from Flickr is accomplished by using Mark Rasmussen's XML Output Fluent Interface, which has really been saving me quite a bit of time lately. You can find the class and implementation examples on his site. In this case, I decided to just wrap it under the default web application namespace. Otherwise you'll need to add the appropriate 'using' statement if you decide to add it to another namespace.  Here is the complete code for the web handler:

The Web Handler

flickrfeed.ashx:

<%@ WebHandler Language="C#" Class="Handler" %>
 
using System;
using System.Web;
using FlickrNet;
 
public class Handler : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        String output;
        context.Response.ContentType = "text/xml";
        context.Response.ContentEncoding = System.Text.Encoding.UTF8;
 
        // Assign the XML document
        output = XMLdata();
 
        context.Response.Cache.SetExpires(DateTime.Now.AddSeconds(600));
        context.Response.Cache.SetCacheability(HttpCacheability.Public);
        context.Response.Write(output);
    }
 
    public bool IsReusable
    {
        get { return true; }
    }
 
    public String XMLdata()
    {
        // Get data
 
        Flickr flickr = new Flickr();
        Photoset photos = flickr.PhotosetsGetPhotos("72157600111054287");
 
 
        // Create XML document
        XmlOutput xo = new XmlOutput()
        .XmlDeclaration()
        .Node("images").Within();
 
        foreach (Photo pic in photos.PhotoCollection)
        {
            String _title = "";
            String _image = "";
            String _thumbnail = "";
 
            if (pic.Title != "")
            {
                _title = pic.Title;
            }
            if (pic.MediumUrl != "")
            {
                _image = pic.MediumUrl;
            }
            if (pic.ThumbnailUrl != "")
            {
                _thumbnail = pic.ThumbnailUrl;
            }
            xo.Node("pic").Within()
            .Node("title").InnerText(_title)
            .Node("image").InnerText(_image)
            .Node("thumbnail").InnerText(_thumbnail)
            .EndWithin();
        }
        return xo.GetOuterXml();
    }
} 

An Example of the XML Output

Flex Gallery

Now that I have my Flickr XML feed up and running the way I want it, I can import it into Flex by retrieving it with HTTPService named "photos" and returning it as E4X:

<mx:HTTPService id="photos" url="flickrfeed.ashx" result="xmlQuery(event)" resultFormat="e4x" />

Note that you may need to use a fully qualified URL, such as "http://www.example.com/directory/flickrfeed.ashx" if you want to host your gallery in a different location than your feed. The HTTPService is launched using the "send()" method via the application's "creationComplete" event:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
     creationComplete="photos.send()" backgroundGradientAlphas="[1.0, 1.0]"
     backgroundGradientColors="[#002579, #1D0000]">

At which point the result event is sent to xmlQuery(event) method to create the thumbnails, load the first image and title. One of my goals for the gallery was to have scrolling thumbnails. This proved a little more difficult than I had anticipated, and I still have work to do on controlling the speed and scrolling bounds more accurately.

The scrolling thumbnail effect is achieved in part by using a simple mask, by nesting the larger HBox containing the thumbnail images within a smaller containing HBox. To keep scroll bars from appearing when the content exceeds the bounds of the container, you must set the verticalScrollPolicy and horizontalScrollPolicy to "off". The Move effects are declared in separate MXML tags and added via event parameters within the individual button controls. You can specify a particular target control for the effects using the "target" parameter in the effect tag, and additionally calling the effect using the "play()" or "stop()" methods from the button control:

<mx:Button label="&gt;" id="rightBtn" mouseOver="mr.play()" mouseOut="mr.stop()"  
     height="40" width="33"/>
 
<mx:Move id="mr" xTo="0" duration="1500" target="{tscroller}" />

Flex Flickr Gallery

You can view the FlexFlickrGallery MXML source here.

Here are a couple of Flex related links I found to be useful:

Again, this is just a first step and I always welcome any suggestions and feedback.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

ASP.NET | Flash

ASP.NET GridView Themes

by Admin 5/31/2008 4:08:00 PM

Cyberslingers GridView Themes

I have posted a few more gridview themes and jazzed up the interface for my preview page a little so that it is easy to switch between different styles and download the source code. I have tried to keep these as simple as possible to implement. You can check them out here.

Currently rated 3.0 by 5 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

ASP.NET

Using a .NET Web Handler to Generate Dynamic XML Feed for Flash

by Admin 5/31/2008 12:44:00 PM

Mark Rasmussen has a really useful XML document fluent interface posted that I have been using for generating XML data feeds for my Flash/Flex projects. While there are certainly alternative methods to acheive the same result, such as LINQ to XMLXMLSerializer or XMLWriter, I have found that Mark's fluent interface is easy to use and has been great for my purposes. What I typically have been doing is creating a web handler, checking the query string for the type of feed required and then sending the appropriate queries to the database to return the desired information that I want to format as XML. The following example certainly has room for improvement - the query string should probably undergo some type of validation and probably a few other things that I haven't even considered yet :-)

Using the interface is as simple as adding his XMLOutput class to your App_Code folder and instantiating it from your page or handler:

<%@ WebHandler Language="C#" Class="Handler" %>

 

using System;

using System.Web;

 

public class Handler : IHttpHandler

{

    public void ProcessRequest (HttpContext context)

    {

        String category = context.Request.QueryString["cat"]; //add validation here

        String output;

        context.Response.ContentType = "text/xml";

        context.Response.ContentEncoding = System.Text.Encoding.UTF8;

 

        // Assign the XML document

        output = XMLdata(category);

 

        context.Response.Cache.SetExpires(DateTime.Now.AddSeconds(600));

        context.Response.Cache.SetCacheability(HttpCacheability.Public);

        context.Response.Write(output);

    }

 

    public bool IsReusable

    {

        get { return true; }

    }

 

    public String XMLdata(String _category)

    {

        // Send query/parameter and get data

        BlogDataSetTableAdapters.ImagesTableAdapter ta = new BlogDataSetTableAdapters.ImagesTableAdapter();

        BlogDataSet.ImagesDataTable dt = ta.GetImages(_category);

 

        // Create XML document

        XmlOutput xo = new XmlOutput()

        .XmlDeclaration()

        .Node("images").Within();

 

        foreach (BlogDataSet.ImagesRow row in dt.Rows)

        {

            String _title = "";

            String _filename = "";

            String _caption = "";

            String _thumbnail = "";

 

            if (row.title != "")

            {

                _title = row.title;

            }

            if (row.filename != "")

            {

                _filename = "images/" + row.filename;

                _thumbnail = "thumbs/" + row.filename;

            }

            if (row.caption != "")

            {

                _caption = row.caption;

            }

            xo.Node("pic").Within()

            .Node("image").InnerText(_filename)

            .Node("title").InnerText(_title)

            .Node("thumbnail").InnerText(_thumbnail)

            .Node("caption").InnerText(_caption)

            .EndWithin();

        }

        return xo.GetOuterXml();

    }

}

 

An Example of the XML Document Output:

 

<?xml version="1.0" encoding="utf-8"?>

<images>

  <pic>

    <image>images/savvy.jpg</image>

    <title>tshirt design for local magazine</title>

    <thumbnail>thumbs/savvy.jpg</thumbnail>

    <caption>tshirt design for local magazine</caption>

  </pic>

  <pic>

    <image>images/Robertsmith.jpg</image>

    <title>Robert Smith Tshirt Design</title>

    <thumbnail>thumbs/Robertsmith.jpg</thumbnail>

    <caption>tshirt design for Robert Smith</caption>

  </pic>

<!--//rest of document//-->

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

ASP.NET

Gamer GridView Theme

by Admin 5/4/2008 6:08:00 AM

Gamer GridView Screenshot 

Live Demo 

Here is another gridview theme I have been playing around with this weekend based on a general CNET GameSpot style. The CSS for the gridview has been put into its own file for this series of posts, so that I can change the look of a gridview quickly without changing the class names that have been assigned to it:

 CSS links in Head tag:

<link href="StyleSheet.css" rel="stylesheet" type="text/css" />

<link href="GamerGridView.css" rel="stylesheet" type="text/css" />

 Standard GridView declaration:

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"

            AutoGenerateColumns="False" CssClass="GridViewStyle" DataKeyNames="CustomerID" DataSourceID="ObjectDataSource1"

            GridLines="None">

            <Columns>

                <!-- Your columns here -->

            </Columns>

            <FooterStyle CssClass="FooterStyle" />

            <RowStyle CssClass="RowStyle" />

            <EmptyDataRowStyle CssClass="EmptyRowStyle" />

            <PagerStyle CssClass="PagerStyle" />

            <SelectedRowStyle CssClass="SelectedRowStyle" />

            <HeaderStyle CssClass="HeaderStyle" />

            <EditRowStyle CssClass="EditRowStyle" />

            <AlternatingRowStyle CssClass="AltRowStyle" />

        </asp:GridView>

I tried a couple of different things on this version, and I am curious if they will work out well enough. In particular, the header styles are based on the links - so changing font sizes or wrapping text in the header will probably break the theme :-(  I don't think I will spend much more time on this one, so I decided to go ahead and post it in the hopes that someone may find it useful.

Here's the contents of GamerGridView.css:

/*GridViewCSS Glass Black Style*/

.GridViewStyle

{

    font-family: Arial, Sans-Serif;

    font-size:small;

    table-layout: auto;

    border-collapse: collapse;

    border: #1d1d1d 1px solid;

}

/*Header and Pager styles*/

.HeaderStyle

{

    background-image: url(Images/HeaderGamer_left.jpg);

    background-position:left;

    background-repeat:repeat-x;

    height:30px;

}

.PagerStyle

{

    background-image: url(Images/PagerGamer.jpg);

    background-position:top;

    background-repeat:repeat-x;

}

.HeaderStyle th

{

    padding: 0px;

    color: #ffffff;

}

.HeaderStyle a:link, a:visited

{

    text-decoration:none;

    color:#ffffff;

    display:block;

    text-align:left;

    font-weight:normal;

    border-left:solid 1px #666666;

    border-right:solid 1px #1d1d1d;

    padding-top:25px;

    padding-bottom:9px;

    padding-right:5px;

    padding-left:5px;

    background-image: url(Images/HeaderGamer.jpg);

    background-position:top;

    background-repeat:repeat-x;

}

.HeaderStyle a:hover

{

    background-image: url(Images/HeaderGamer_Hover.jpg);

    background-position:top;

    background-repeat:repeat-x;

}

.PagerStyle table

{

    text-align:center;

    margin:auto;

}

.PagerStyle table td

{

    border:0px;

    padding:5px;/*padding around pager numbers */

}

.PagerStyle td

{

    border-top: #1d1d1d 1px solid;/*top border of pager*/

    height:40px;

}

.PagerStyle a

{

    color:#ffffff;

    text-decoration:none;

    padding:2px 10px 2px 10px;

    /*border around pager numbers*/

    border-top:solid 1px #777777;

    border-right:solid 1px #333333;

    border-bottom:solid 1px #333333;

    border-left:solid 1px #777777;

}

.PagerStyle span

{

    font-weight:bold;

    color:#FFFFFF;

    text-decoration:none;

    padding:2px 10px 2px 10px;

}

/*RowStyles*/

.RowStyle td, .AltRowStyle td, .SelectedRowStyle td, .EditRowStyle td /*Common Styles*/

{

    padding: 5px;

    border-right: solid 1px #1d1d1d;

}

.RowStyle td

{

    background-color: #333333;

    color: #ffffff;

}

.AltRowStyle td

{

    background-color: #1d1d1d;

    color:#ffffff;

}

.SelectedRowStyle td

{

    background-color: #ffff66;

}

And the images:

Pager image Pager image (jpg)

Pager image Pager image native (Fireworks PNG)

Header image Header image (jpg)

 

Header image Header image native (Fireworks PNG)

 

Header image Header image - left side (jpg)

 

Header image Header image - Hover (jpg)

Currently rated 2.3 by 3 people

  • Currently 2.333333/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

ASP.NET

Glassy Black GridView Theme

by Admin 5/4/2008 6:05:00 AM

Live Demo

Overview

I have been following Matt Berseth's posts covering DataGrid designs and decided to try a create my own theme. This theme is entirely CSS based on a standard GridView control using .NET 2.0. I've only tested it with Firefox 2 and IE7 so far, so there may be some lingering CSS issues to resolve.

Installation

Once you drag a default GridView onto the page, you will need to set the appropriate CSSclass for the GridView and each RowStyle as well as set GridLines to None:

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"

    AutoGenerateColumns="False" CssClass="GridViewStyle" GridLines="None">

    <Columns>

        <!-- Bound field parameters go here -->

    </Columns>

    <RowStyle CssClass="RowStyle" />

    <EmptyDataRowStyle CssClass="EmptyRowStyle" />

    <PagerStyle CssClass="PagerStyle" />

    <SelectedRowStyle CssClass="SelectedRowStyle" />

    <HeaderStyle CssClass="HeaderStyle" />

    <EditRowStyle CssClass="EditRowStyle" />

    <AlternatingRowStyle CssClass="AltRowStyle" />

</asp:GridView>

If you do not already have a stylesheet attached to your page, you will need to create one using "Add New Item" and make sure it is referenced in the <head> of you web page. Assuming you named your stylesheet the default "Stylesheet.css", your <head> tag should look something like this:

<head id="Head1" runat="server">

    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />

</head>

And here is the CSS:

/*GridViewCSS*/

.GridViewStyle

{

    font-family: Arial, Sans-Serif;

    font-size:small;

    table-layout: auto;

    border-collapse: collapse;

    border: #1d1d1d 5px solid;

}

/*Header and Pager styles*/

.HeaderStyle, .PagerStyle /*Common Styles*/

{

    background-image: url(Images/HeaderGlassBlack.jpg);

    background-position:center;

    background-repeat:repeat-x;

    background-color:#1d1d1d;

}

.HeaderStyle th

{

    padding: 5px;

    color: #ffffff;

}

.HeaderStyle a

{

    text-decoration:none;

    color:#ffffff;

    display:block;

    text-align:left;

    font-weight:normal;

}

.PagerStyle table

{

    text-align:center;

    margin:auto;

}

.PagerStyle table td

{

    border:0px;

    padding:5px;

}

.PagerStyle td

{

    border-top: #1d1d1d 3px solid;

}

.PagerStyle a

{

    color:#ffffff;

    text-decoration:none;

    padding:2px 10px 2px 10px;

    border-top:solid 1px #777777;

    border-right:solid 1px #333333;

    border-bottom:solid 1px #333333;

    border-left:solid 1px #777777;

}

.PagerStyle span

{

    font-weight:bold;

    color:#FFFFFF;

    text-decoration:none;

    padding:2px 10px 2px 10px;

}

/*RowStyles*/

.RowStyle td, .AltRowStyle td, .SelectedRowStyle td, .EditRowStyle td /*Common Styles*/

{

    padding: 5px;

    border-right: solid 1px #1d1d1d;

}

.RowStyle td

{

    background-color: #c9c9c9;

}

.AltRowStyle td

{

    background-color: #f0f0f0;

}

.SelectedRowStyle td

{

    background-color: #ffff66;

}

The last step is to create a folder in your root directory titled "Images" and add the background image "HeaderGlassBlack.jpg" to it. That should do it!

Currently rated 4.2 by 5 people

  • Currently 4.2/5 Stars.
  • 1