Posts Tagged ‘developers’

April 22nd, 2013
Comments Off

34 Free Open Source CSS Code Snippets for Developers

With a quick Google search you will find a ton of handy CSS2/CSS3 code snippets. But what about pre-built CSS web interfaces? There are some cool widgets and samples out there, but it can be difficult finding great high-quality releases. I think developers really treasure open source codes for the fact that it saves a lot of time putting together more complicated websites.

In this showcase gallery I have organized 34 outstanding and free CSS code snippets. All of these examples provide some type of website interface element such as forms, buttons, tables, switches, pagination, and other common items. Be sure to check out the gallery listing to get a better idea of what you may be able to use in your own website(s). All items are provided by CSSFlow which you can download for free and include on any number of projects.

Glossy Buttons

bright css3 glossy buttons

Facebook Login Form

css html website login form effects input

Dark Datepicker

dark website interface date picker ui

Pricing Table

css3 html5 pricing table buttons freebie

Social Buttons

css3 social media buttons designs

Notification Windows

css3 warning windows html5 open source

Dark and Light Dropdowns

select menu lists input form dark light ui

Newsletter Signup Form

newsletter signup subscribe box effect

Dark Pagination

dark pagination ui effects website

Settings Panel

mac osx settings input panel css3 open source

Multi-colored Buttons

shiny multi-colored buttons css3 html5

Notification Badges

small css3 icons badges notify ios navigation freebie

Flip-Down Clock

static css3 clock paper effects rolodex

Share Buttons

Modal Contact Form

bright modal contact form input effects css3

Notepaper Blockquote

css3 notepaper block quote effect

Toggle Switches

pure css3 user input toggle switches open source

Metal Progress Bar

metal progress bar ui html5 css3 freebie

OSX-Style Window

transparent mac osx window made using css3 html5

Search Dropdown

search input dropdown menu suggested open source

Mini Social App

mini twitter social app ui interface css3 freebie

Month Picker

css3 generated input freebie month selection

Animated Progress Bar

css3 animated progress bar interface ui

Inset Side Navigation

inset side navigation effects freebie open source

Login Form

cssflow freebie snippet login form css3 html5 download

Dark Navigation

horizontal dark navigation tabs menu links

Light Horizontal Nav

light horizontal navigation bar tabs links freebie open source

Dark Horizontal Nav

dark block buttons navigation links css3 html5

Animated Profile Popover

user profile features popover hover effects open source

3D Buttons

html css3 3-d buttons freebie download codes

Sliding Tags

sliding blog tags posts count number jquery css3

Accordion Menu

vertical html5 css3 accordion menu interface design

Tabbed Navigation

css3 tabbed navigation toolbar effects design

Mini Dropdown Menu

dark dropdown menu css3 mini effects ui

May 13th, 2010

ASP.NET for PHP Developers – Part II

In part one of the “ASP.NET for PHP Developers” tutorial, we learned the basics of ASP.NET and the C# language. Part
two builds on that foundation, and introduces some more advanced features and techniques to take your ASP.NET
pages to the next level.

Tutorial Details

  • Technology: ASP.NET (C#)
  • Difficulty: Advanced
  • Estimated Completion Time: 1 hour
  • Part: 2 of 2

Before you Start…

Ensure you have read and completed the examples in part 1 of the tutorial. We’ll be building on that application here.
It’s also worth stressing that you need a good grasp of object oriented programming (OOP) to continue.

And Before I Start…

I mentioned in part 1 of the tutorial that there are two flavours of ASP.NET available:

  • ASP.NET WebForms: the original framework allowing developers to create web applications using many of the same techniques used in .NET Windows desktop applications
  • ASP.NET MVC: a newer framework offering Model-View-Controller architecture and more control over client-side code

However I don’t use either of those, but rather a third approach of my own devising. That’s for several reasons:

  1. When I started writing serious ASP.NET applications I retained my high standards of HTML output learned when writing PHP. If the page didn’t validate I felt dirty. There are a lot of developers who feel the same. ASP.NET WebForms gave, at the time, awful markup for many of the standard controls, so I had to come up with another solution. Adding runat="server" to HTML elements offered many of the advantages of true ASP.NET controls, but gave me full control over the HTML that was outputted. Things improved, and are looking even better for ASP.NET 4.0.
  2. I saw lots of examples of ASP.NET code where it was obvious the developer didn’t care about the resulting HTML. Perhaps they were Windows desktop application developers making the jump to the web, maybe they had never hand-coded HTML. Whatever the reason, I determined I would not be one of them.
  3. Quite a few of the standard ASP.NET controls relied entirely on JavaScript which is, to be frank, unforgivable for public websites (in the UK web accessibility is a legal requirement). For example, the evil javascript:__doPostBack function is a perfect way to make your website impossible to use for a large proportion of the web audience – oh, and search engines as well.
  4. I wanted to use my own choice of JavaScript library (initially Prototype, but then jQuery, now officially supported by ASP.NET). If I had to use the ASP.NET framework JavaScript library it would have made that more difficult.
  5. So why not ASP.NET MVC? Well, it wasn’t around when I started writing ASP.NET applications, and even if it was it would have been another hurdle to jump to get anything to work. Learning the .Net framework and C# language was challenging enough!

So you can see why I chose this "roll-your-own" approach. As ASP.NET matured and I discovered new features, I started to integrate those into my applications, and I fully expect that over time I’ll be doing more of that.

So, let’s take our ASP.NET application to the next level.

Master Pages

My second favourite feature of ASP.NET (after turning HTML controls into server controls) is master pages. A master page is a template file you can use to encapsulate HTML you use in multiple pages. For example, your master page could contain the header, menu and footer of your pages, while your normal .aspx pages contain the actual content on that page. let’s look at an example web page:

A sample web page

You can see the parts which are used on multiple pages highlighted in green. The content which changes for each page in the site is highlighted in red. Master pages allow us to split up the code for these two sections into multiple files. If you’ve used templates in your PHP applications (for example WordPress has header.php, footer.php and sidebar.php) you’ll see how great master pages are.

Creating a master page

So let’s create a master page. In the Solution view create a new directory in your ASP.NET application called "Master_Pages". In that directory create a new master page by right-clicking on the Master_Pages folder, selecting "Add > New file" then selecting "Master Page with Code Behind" and call it "DefaultMaster". Your new master page will be created and you’ll see the "DefaultMaster.master", "DefaultMaster.master.cs" and "DefaultMaster.master.designer.cs" files in the Master_Pages folder.

A new master page in MonoDevelop

Open the "DefaultMaster.master" and "DefaultMaster.master.cs" files. The code-behind file (.cs) for the master page (.master) works exactly the same as the code-behind file for an .aspx page. The first thing to note is master pages do not inherit from System.Web.UI.Page like .aspx pages do. Instead they inherit from System.Web.UI.MasterPage. Here’s the default code for the code-behind.

using System; using System.Web; using System.Web.UI; namespace WebApplication1 { public partial class DefaultMaster : System.Web.UI.MasterPage { } }

And for the .master file itself:

<%@ Master Language="C#" Inherits="WebApplication1.DefaultMaster" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>DefaultMaster</title> </head> <body> <div id="container"> <form runat="server"> <asp:contentplaceholder id="contentPlaceHolder" runat="server" /> </form> </div> </body> </html>

Because we’re not using the WebForms model, let’s quickly remove the tags for the <form runat="server"> element.

You should be getting used to page declarations (the <%@ Page ... %> bit in .aspx pages) by now, so the <%@ Master ... %> declaration will come as no surprise. What is different in this code is a new control: <asp:contentplaceholder>.

<asp:contentplaceholder id="contentPlaceHolder" runat="server" />

This content placeholder is where the content from your .aspx pages will be inserted. You can have as many of these in a .master page as you like.

Referencing your master page

Let’s go back to our normal .aspx page and make some edits. The first thing to do is remove the <html>, <head> and <body> tags, as they will now be in the master page. That leaves:

<%@ Page Language="C#" Inherits="WebApplication1.Default" %>

<h1 id="headertext" runat="server">This is the text</h1>

Now we need to specify what content to place in the content placeholder. We do that by specifying where the master page is, and wrapping our content in an asp:Content control, like this:

<%@ Page Language="C#" MasterPageFile="~/Master_Pages/DefaultMaster.master" Inherits="WebApplication1.Default" %> <asp:Content id="Content1" ContentPlaceHolderID="contentPlaceHolder" runat="server"> <h1 id="headertext" runat="server">This is the text</h1> </asp:Content>

There’s a couple of things to note here. Firstly the Page declaration has an additional attribute of "MasterPageFile" with a value of "~/Master_Pages/DefaultMaster.master". In ASP.NET "~" means the root of the application, the rest of that path just points to our master page.

Secondly you see the new asp:Content control has an attribute of "ContentPlaceHolderID" with a value of "contentPlaceHolder", which is the "id" attribute of our <asp:contentplaceholder>. Running the application will give you:

An ASP.NET master page and content page working together

Checking the source code of the page proves that the master page (.master) and content page (.aspx) have been seamlessly integrated together. Now you see why I love master pages so much.

A more complex master page

We can push master pages a lot further than this simple example. Let’s have a go at building something that looks more like a real web application, starting with the master page. Firstly we’ll add some more content placeholders and a few server-side controls:

<%@ Master Language="C#" Inherits="WebApplication1.DefaultMaster" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title><asp:contentplaceholder id="PageTitle" runat="server" /></title>

<script src="scripts/jquery.min.js"></script> <asp:contentplaceholder id="PageJS" runat="server" />

<link rel="stylesheet" href="styles/default.css"></link> <asp:contentplaceholder id="PageCSS" runat="server" /> </head> <body> <div id="container">

<h1 id="sitename" runat="server"></h1>

<ul id="menu"> <li><a href="about.aspx">About me</a></li> <li><a href="services.aspx">My services</a></li> <li><a href="contact.aspx">Contact me</a></li> </ul>

<div id="content"> <asp:contentplaceholder id="PageContent" runat="server" /> </div>

<div id="footer"> <p id="copyright" runat="server"></p> </div>

</div> </body> </html>

And in the code-behind file for our master page we’ll put:

using System; using System.Web; using System.Web.UI; using System.Configuration;

namespace WebApplication1 { public partial class DefaultMaster : System.Web.UI.MasterPage { protected void Page_Load(object sender, EventArgs e) { sitename.InnerHtml = ConfigurationSettings.AppSettings["SiteName"]; copyright.InnerHtml = ConfigurationSettings.AppSettings["CopyrightNotice"] + DateTime.Now.Year.ToString(); } } }

(I’ll leave it as an exercise for you to add the SiteName and CopyrightNotice applications settings to web.config.)

Now for our content page. We have four content placeholders we can use: PageTitle, PageJS, PageCSS and PageContent. Here’s the code for the .aspx content page:

<%@ Page Language="C#" MasterPageFile="~/Master_Pages/DefaultMaster.master" Inherits="WebApplication1.Default" %>

<asp:Content id="PageTitle" ContentPlaceHolderID="PageTitle" runat="server"> <asp:Literal id="Title" runat="server"></asp:Literal> </asp:Content>

<asp:Content id="PageCSS" ContentPlaceHolderID="PageCSS" runat="server"> <style type="text/css"> h1 { font-family: sans-serif; color: #090; } </style> </asp:Content>

<asp:Content id="PageContent" ContentPlaceHolderID="PageContent" runat="server">

<h2>Welcome, one and all</h2> <p>This is my very first ASP.NET website, working with a master page!</p>

</asp:Content>

And the code-behind for our .aspx content page:

using System; using System.Web; using System.Web.UI; using System.Configuration;

namespace WebApplication1 { public partial class Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Title.Text = "Welcome to my first ASP.NET Website"; } } }

A couple of new things to notice here. Firstly I haven’t used the PageJS content placeholder at all – it’s quite OK to leave it out entirely (of course nothing will be rendered to the page for that area). Secondly I’ve introduced another ASP.NET control, namely <asp:Literal>, which we’ll take a quick look at now.

The Literal control

The Literal control is very useful when you want to render something to the page without any extra markup. For example, a lot of the time it’s fine to use:

<span id="message" runat="server"></span>

message.InnerHtml = "This is the message"

Gives:

<span id="message">This is the message</span>

But if you don’t want the span tags at all, for example for the page <title>, you need the Literal control. Setting the "Text" property of the Literal control renders just that text to the page:

<asp:Literal id="message" runat="server"></asp:Literal>

message.Text = "This is the message";

Gives:

This is the message

The completed master and content page

So running our application should give us this:

An ASP.NET master page and content page with multiple content placeholders

This is really just scratching the surface, as it’s possible to have multiple master pages (even nested master pages!). You can also set the master page programatically (but this needs to be done in the Page_Init event, as Page_Load is too late in the page lifecycle). There’s lots more detail about MasterPages on the MSDN site.

Custom Classes

It’s possible to create custom classes in your application, just like you would in PHP. Let’s create a security class by right-clicking the root of your application and selecting "Add > New file" then choosing "Empty class" from the "General" section and calling it "Security".

An new empty class

The code for your new class looks like this:

using System; namespace WebApplication1 { public class Security { public Security() { } } }

I’ll throw a bit more code into this file:

using System; using System.Web; namespace WebApplication1 { public class Security { public bool IsLoggedIn; public Security() { CheckSession(); } private void CheckSession() { if (HttpContext.Current.Session["loggedin"] != null && HttpContext.Current.Session["loggedin"] == "true") { IsLoggedIn = true; } else { IsLoggedIn = false; } } } }

Pretty simple so far. The only new thing is the use of HttpContext.Current.Session rather than just Session, that’s because HttpContext.Current is implicit in an .aspx web page, but not in a standalone class.

In our Default.aspx.cs code-behind file we write:

protected void Page_Load(object sender, EventArgs e) { Security security = new Security(); if (security.IsLoggedIn) { Title.Text = "Welcome back, you are logged in"; } else { Title.Text = "You are not logged in"; } }

Which instantiates a new instance of the Security class names "security". Running the application shows this:

Not logged in

As you’re familiar with OOP you can see how this can be used to build large-scale web applications. The only other thing to say about custom classes is how to make them static. Here’s the code for a static class:

using System; using System.Web; namespace WebApplication1 { public static class Security { public static bool IsLoggedIn; public static void CheckSession() { if (HttpContext.Current.Session["loggedin"] != null && HttpContext.Current.Session["loggedin"] == "true") { IsLoggedIn = true; } else { IsLoggedIn = false; } } } }

You can see there’s no default method, as this class is never instantiated. I’ve also added the "static" keyword to the property and method, and I’ve made the CheckSession() method public. To use this static class we would write:

protected void Page_Load(object sender, EventArgs e) { Security.CheckSession(); if (Security.IsLoggedIn) { Title.Text = "Welcome back, you are logged in"; } else { Title.Text = "You are not logged in"; } }

Pretty simple, really. As you’re fully aware of the advantages that OOP can give you for abstraction, encapsulation and inheritance you’ll see how powerful this is. But if we’re going to use objects, we really need some serious data to model in our objects. We need a database.

Databases, Data Sources and Data Binding

ASP.NET works really well with databases, but works the best with Microsoft SQL Server (not surprisingly). Even if your ASP.NET application is running on a Linux box, you can still connect to SQL Server on a Windows server to use as a datastore. I’ll demonstrate that below, but as I’m writing this tutorial in Linux I will also demonstrate the use of MySQL as an ASP.NET database. To use MySQL you’ll need the ADO.NET driver for MySQLthis excellent article helped me a lot.

Database configuration

The first thing to do is configure how to connect to our database server. You can do this in web.config, add this code inside the "configuration" section (the MySQL and SQL Server code should be pretty obvious). Note that these are standard connection strings.

<connectionStrings> <add name="MySQL" connectionString="Server=mysqlserver;Database=aspnetdb1;User ID=root;Password=mypassword;Pooling=false"/> <add name="SQLServer" connectionString="Server=sqlserver;Database=aspnetdb1;User ID=sa;Password=myPassword;"/> </connectionStrings>

I’ve also created a table called "users" with this code (this is for MySQL, minor edits will make it work in most other database systems):

CREATE TABLE users ( id int  NOT NULL AUTO_INCREMENT, username varchar(50)  NOT NULL, password varchar(32)  NOT NULL, email varchar(255)  NOT NULL, PRIMARY KEY (id) );

To access your connection string you can use the ConfigurationManager class which we used in part 1 of the tutorial to access global configuration settings. Here’s the code:

string conn = ConfigurationManager.ConnectionStrings["MySQL"].ConnectionString;

Connecting and running a simple query

So we’re now ready to connect to our database and run a query. First, insert a couple of rows into the " users" table so we have something to query:

insert into users (username, password, email) values ('User 1', 'user1password', 'user1@asp.net')

We then need to ensure we reference the right assemblies. For MySQL make sure you have this at the top of your code-behind file:

using System.Data; using MySql.Data.MySqlClient;

Amd for SQL Server use this:

using System.Data; using System.Data.SqlClient;

A quick note about connecting to MySQL in Linux. I had a bit of trouble making my application compile when I first tried this. I did various searches but found no answer that worked for me. The error I got was "The type or namespace name `MySqlConnection’ could not be found." which looked like the MySQL Connector wasn’t installed properly. The fix (for me) was to manually add the reference by right-clicking the References folder in my application and going to "Edit references". I then found the MySQL.Data.dll file in the .Net Assembly tab and referenced it. I also had to then manually reference the System.Data and System.Configuration assemblies from the Packages tab.

MonoDevelop references

Hopefully you won’t need to jump through these hoops.

We now open a connection to our database like this for MySQL:

protected void Page_Load(object sender, EventArgs e) { // get the connection string string conn = ConfigurationManager.ConnectionStrings["MySQL"].ConnectionString; // create a new MySQL connection MySqlConnection dbcon; using (dbcon = new MySqlConnection(conn)) { // open the connection dbcon.Open(); // create the query string query = "SELECT username, email FROM users"; // create a new adapter between the connection and query MySqlDataAdapter adapter = new MySqlDataAdapter(query, dbcon); // create a new dataset to store the query results DataSet ds = new DataSet(); // fill the dataset with the results from the adapter, // the name of the dataset is "result" adapter.Fill(ds, "result");

} }

And this for SQL Server:

protected void Page_Load(object sender, EventArgs e) { // get the connection string string conn = ConfigurationManager.ConnectionStrings["SQLServer"].ConnectionString; // create a new SQL Server connection SqlConnection dbcon; using (dbcon = new SqlConnection(conn)) { // open the connection dbcon.Open(); // create the query string query = "SELECT username, email FROM users"; // create a new adapter between the connection and query SqlDataAdapter adapter = new SqlDataAdapter(query, dbcon); // create a new dataset to store the query results DataSet ds = new DataSet(); // fill the dataset with the results from the adapter, // the name of the dataset is "result" adapter.Fill(ds, "result");

} }

See, pretty easy, and not a million miles away from the equivalent PHP code. There are a couple of bits in here I’ll explain in some more depth. Firstly the using statement:

using (something here) { ... }

The object you set up in the brackets is automatically destroyed when your code leaves the end curly brace "}". This is a really useful structure to know about, so read all about it here.

Secondly the DataSet. In the code above the results from the database query are fed into a DataSet, which is an object containing one or more tables, each table containing rows and columns. That means you can do useful things like:

DataSet ds = new DataSet(); // we put some data from the database in the DataSet here... // get the number of tables int tables = ds.Tables.Count; // get the first table DataTable dt = ds.Tables[0]; // get the number of rows in the first table int rows = ds.Tables[0].Rows.Count;

And there are many other goodies in the DataSet class. You can also loop rows, just like you do in PHP, like this:

for (int x = 0; x < ds.Tables[0].Rows.Count; x++) { Response.Write(ds.Tables[0].Rows[x]["fieldname"].ToString() + <br />); }

But there’s a much better way to display simple loops, and that’s using the Repeater control.

Using repeaters and databinding

First a confession. There are large ASP.NET applications I’ve written that use no ASP.NET controls except the Literal (which we looked at above) and the Repeater. The Repeater control allows you to "bind" data, for example from a DataSet, and display it in a looped manner. Firstly we need to add something to our database code above:

protected void Page_Load(object sender, EventArgs e) { // get the connection string string conn = ConfigurationManager.ConnectionStrings["MySQL"].ConnectionString; // create a new MySQL connection MySqlConnection dbcon; using (dbcon = new MySqlConnection(conn)) { // open the connection dbcon.Open(); // create the query string query = "SELECT username, email FROM users"; // create a new adapter between the connection and query MySqlDataAdapter adapter = new MySqlDataAdapter(query, dbcon); // create a new dataset to store the query results DataSet ds = new DataSet(); // fill the dataset with the results from the adapter, // the name of the dataset is "result" adapter.Fill(ds, "result");

// below is the new code...

// set the DataSource of the repeater myRepeater.DataSource = ds; // bind the data myRepeater.DataBind();

} }

And in the .aspx page we put:

<asp:Repeater id="myRepeater" runat="server"> <HeaderTemplate> <table> <tr> <th>Username</th> <th>Email</th> </tr> </HeaderTemplate> <ItemTemplate> <tr> <td><%# Eval("username") %></td> <td><%# Eval("email") %></td> </tr> </ItemTemplate> <AlternatingItemTemplate> <tr class="alt"> <td><%# Eval("username") %></td> <td><%# Eval("email") %></td> </tr> </AlternatingItemTemplate> <FooterTemplate> </table> </FooterTemplate> </asp:Repeater>

You can see what happens here. When the data is bound to the Repeater control the HeaderTemplate section is displayed. Then each row is displayed in the ItemTemplate and AlternatingItemTemplate sections (the names should give you a clue how they are displayed). Then finally the FooterTemplate section is displayed. Using this simple control gives you an easy way to display repeating data, with complete control over the resulting HTML – just like you would do in PHP. Here’s the results (with some CSS for styling):

A simple example of a Repeater control

As a Repeater will throw an Exception if an empty DataSet is bound to it, you need to check there is data to be bound first. A simple if statement will work, checking if there are tables in the DataSet and if the first table has rows:

if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { myRepeater.DataSource = ds; myRepeater.DataBind(); }

I think you’ll agree that having a control which sets templating for repeating data as easily as that is a massive help to the developer. One thing to note with the Repeater control – if you bind a DataSet to it by default the first table is used. If you’re using stored procedures instead of inline SQL to run commands against your database you can return multiple tables, meaning you can load several sets of data for use in a page at once. In that case you’d use code like this (to bind the second table in the DataSet to the Repeater):

myRepeater.DataSource = ds.Tables[1]; myRepeater.DataBind();

Creating a data access class

Let’s pull the last couple of sections together and create a data access class that will simplify connecting to and running commands on your database. This code is for MySQL, but as you’ve seen the code for SQL Server is very similar. Create a new empty class called "DB" and paste this into the new file:

using System; using System.Configuration; using System.Data; using MySql.Data.MySqlClient;

namespace WebApplication1 { public class DB { private string ConnectionString; public DB() { // get the connection string this.ConnectionString = ConfigurationManager.ConnectionStrings["MySQL"].ConnectionString; } public DataSet Select(string query) { MySqlConnection dbcon; using (dbcon = new MySqlConnection(this.ConnectionString)) { // open the connection dbcon.Open(); // create a new adapter between the connection and query MySqlDataAdapter adapter = new MySqlDataAdapter(query, dbcon); // create a new dataset to store the query results DataSet ds = new DataSet(); // fill the dataset with the results from the adapter, adapter.Fill(ds, "result"); // return the dataset return ds; } } public bool Execute(string query) { MySqlConnection dbcon; using (dbcon = new MySqlConnection(this.ConnectionString)) { // create a new SQL command on thie connection MySqlCommand command = new MySqlCommand(query, dbcon); // open the connection dbcon.Open(); // execute the query and return the number of affected rows int affectedrows = command.ExecuteNonQuery(); // there were no rows affected - the command failed if (affectedrows == 0) { return false; // the command affected at least one row } else { return true; } } } } } 

To use this in your code-behind file you’d put:

DB db = new DB(); DataSet ds = db.Select("SELECT username, email FROM users"); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { myRepeater.DataSource = ds; myRepeater.DataBind(); }

This data access class introduces you to a new style of database connection syntax using the MySqlCommand class (SqlCommand for SQL Server) and the ExecuteNonQuery method. As the code says, the ExecuteNonQuery method executes a query and returns the number of affected rows. Very useful for INSERT, UPDATE and DELETE commands.

Those of you with a good knowledge of WordPress will see how this class is similar to the $wpdb global class in WP which offers methods like $wpdb->get_results("select * from table"); and $wpdb->query("delete * from table");. It would be easy for you to extend this data access class to have more useful properties and methods for your applications.

User Controls

So far we’ve used just two ASP.NET controls – Literal and Repeater – in honour of our aim to keep full control of the output HTML. But sometimes it’s useful to encapsulate functionality for your own controls. ASP.NET allows you to create user controls with properties and methods all your own. These user controls can be thought of as discrete blocks of HTML that can be used inside a .aspx page, just like you’d include a separate file in a .php file.

We’re going to create a very simple control that displays a truncated link. Firstly add a new file of type "User control with code-behind file" and call it "ShortLink".

Adding a new user control

You may notice the new file has an extension of .ascx, this is the extension for user controls. Open the .ascx file and you’ll see this:

<%@ Control Language="C#" Inherits="WebApplication1.ShortLink" %>

Open the code-behind file (MyControl.ascx.cs) and you’ll see this:

using System; using System.Web; using System.Web.UI;

namespace WebApplication1 { public partial class MyControl : System.Web.UI.UserControl { } }

Continue Learning…

May 10th, 2010

90+ Fresh Posts for Designers and Developers


Fresh Posts for Designers and Developers

This post is a collection of latest community news submitted on tripwire magazine by readers and other blog owners.  Most new posts in the web design and development community is included making this regular post a really fast and easy consumable overview of what is going on just now.  You can find more community news here

Create an Wooden Background Website Layout in Photoshop

In this post we will show you how to create a website using splatter brush and few cool techniques. You can customize it for a company or own web site.

10 Firefox Addons Every Web Designer Should Know

If you are web designer you absolutely use firefox because of Firefox has some cool add-ons which make the job of website designers much easier and fast.

31 Stunning Black And White Photographs

The world of photograhy is a world of passion which touches many hearts. This compilation consists of black and white pictures divided into categories.

50+ Free Fonts Collection for Web Designers and Logo Artists

Fonts should speak itself about the product. So in this article you can find some excellent font collection for logo and web designing.

How to Convert a WordPress Blog into WordPress MU

WordPress is one of the best and very popular blogging platforms which is not only free but also released as a open source project.

10 Tips For Becoming A More Efficient Web Designer

This article provides ten tips and techniques that you can use to become a more efficient and productive web designer.

Free Social Network Icons from IconShock

IconShock has designed Social Network icon-set exclusively for Smashing Share readers. The IconShock – icon sets are awesome and free to use for both your personal and commercial projects.

Learn how to create a clean busines layout

Learn how to create a clean business layout with this step by step tutorial.

50 Inspiring Sites Using Red As Their Main Color

I like the red colour a lot (makes me think of Dracula). And we already know that the web is full of great examples of web designs (using red or not) to get some inspiration from [..]

Design Envy : Make it Work For You!

It’s natural, it happens to the best of us. And it is certainly nothing to be ashamed of.

Whats the Best way to Promote your Latest Article?

There are several ways in which to achieve this, and I hope to discuss two of the easiest and simple in which to setup and carry out.

21 Wonderful Logos for your Daily Dose of Inspiration

The probably most important thing of a Brand is the Logo, It gives the Costumer/viewer a Images to the Brand Name. Even Business owners now how important the logo is for their Brand….

How to Find the Best Keywords and Ideas for Your Articles

Today, in this article we will show you how to find best SEO keywords the easy way. The next 5 tools are in the top of my keywords generators.

How to Create Perfect Radial Shapes in Illustrator

In this tutorial, It will walk you through the creation process on how to effectively recreate some perfect radial shapes.

How To Create A Retro Style Text Effect Using Illustrator

In this tutorial It explains how to easily create a 3d text and merge it into a retro-style scene. We will use Illustrator for the text,

Ten Dirty Secrets of Web Hosting Services

When looking for a web hosting service, you should be careful as there are a lot of things they may try to hide from you.

Proportion: Definition and Gallery

Proportion (or scale) refers to the relative size and scale of the various elements in a design. In essence, this takes design elements and contrasts their sizes greatly for emphasis.

Eight Greatest Things About Open Source

Linux Environment: This is a given, granted, but no one can exclude the brainchild of Linus Torvalds when talking about open source. What was begun as a learning experience…

What You Should NEVER do With Your Web Hosting Account

t should go without saying that one of the biggest data protection “faux-pas” is keeping your critical data backups on-site after they’ve been copied. In the event of theft, flooding..

50+ Creative Business Card Designs

Do you need the creative Business for your Business? We assembled Fresh collection stimulate your creative juices for your own beautiful business.

50+ Unique and Inspiring Blue Logo Designs

This 50+ Unique and Inspiring Blue Logo Designs are especially compiled for logo designers who are momentarily out of ideas.

The Guide To Landing A Graphic Design Job

The first question in this new series tackles the dilemma of finding a job as a Graphic Designer without much actual design experience.

35 Ultimate Useful Android Applications

Andriod (Google mobile operating system) market is growing day by day as this OS giving lot of user friendly applications, some of those listing today as our visitors and readers demand. Android on..

Golden Fish – Free Illustration

If your website is about pets or fishes, feel free to download this illustration. Not only it’s well done but also free to use.

Codeigniter shopping cart v1.1 Part 15: contact page and sending email message

Contact page allows visitors to send a message through a form. It has a reCaptcha in order to avoid spam. I will cover the contact page and sending email message to an administrator in this article.

Quote Portal for iPhone is The Epitome of Simplicity and Brilliance

Quote Portal has one of the nicest interfaces I have ever seen on an iPhone app. The concept is completely basic, yet the UI is so good, it transforms this app into a keeper. So what does the app do?

Coffee Shop Posters: 17 Creative Design Examples

Coffee shop posters can set the mood, provoke discussion, wake creativity, and express the shop’s unique identity and style.

Photography By Warwick Saint

Warwick Saint was born in South Africa in 1972. With a Creative dad and a Model mom, it was not surprising Warwick Saint was to become a photographer.

Over 500 Beautiful Frames

Here are over 500 Beautiful Frames for you. These frames can be used for making different Wish cards. All Frames are Zipped in a file, some of these are inserted directly so you can view these.

3 Best Solutions to make your own custom Linux

Linux is fun so much fun. It gives you awesome multidimensional opportunities to experiment. Its not just bunch of distros with colorful desktop environments.

15 Gothic Fonts for Designers

This is the seventh post of our awesome fonts series. Last time we posted a collection of free grunge fonts now in this post you will find 15 Gothic Fonts for Designers.

Over 800 Beautiful Backgrounds

I’ve collected a large number of Beautiful Backgrounds. You can use these backgrounds as your Website Bg. All backgrounds are present in a ZIP file, preview also available.

22 Fresh Web Design Tutorials using Photoshop for 2010

I have compiled a list of 22 of the latest web design tutorials released in 2010.

Top 3 Internal link building Tactics

Internal link building plays a crucial role in ensuring that all the relevant pages of your website gets crawled by the search engines.

Showcase Of Web Design In Ukraine

Here is a showcase of web design agencies and the latest trends in web design of Ukraine.

continue reading…

February 23rd, 2010

70+ Need to Check Out Posts for Designers and Developers

70+ Need to Check Out Posts for Designers and Developers

This post is a collection of latest community news submitted on tripwire magazine by readers and other blog owners.  Most new posts in the web design and development community is included making this regular post a really fast and easy consumable overview of what is going on just now.  You can find more community news here

Photography by Leigh Taylor

Orlando wedding and engagement photographer. Leigh Taylor Photography is an award winning, natural light, on location photographer

Fresh Icon Sets You Probably Haven’t Seen Before

New icon sets are published every day on web design blogs. I have monitored many of these blogs a long time and I thought, therefore, show some of the best-looking icon sets I’ve seen recently.

Why Olympic Posters Are Terrible

Olympic posters have evolved a great deal over the last hundred years or so. David Ross, former Art Director of the San Francisco Museum of Modern Art, talks about it.

20 Eye Catchy Free 3D Fonts For Your Next Designs

In this article you will find 20 Eye Catchy Free 3D Fonts For Your Next Designs that can improve user experience. If you are designing a poster and you would like to add a some depth to it, maybe

25 Beautiful Portrait photography of Various Animals

25 Beautiful Portrait photography of Various Animals by amazing photographers

50+ sets of Latest Photoshop color gradients

If you are a web or a Graphic Developer then Adobe Photoshop is a necessary tool. If you want to do powerful work quickly then your Photoshop application should be

Weekly Inspiration No. 05

If you’re looking for something to inspire yourself then you just have to take a look at our new weekly blog. Enjoy this sensational collection of creative art work and design!

50 Beautiful Examples of Red Logo Designs for Inspiration

These 50 Beautiful Examples of Red Logo Designs for Inspiration will surely lighten up your day and will make you feel the love surrounding you this season.

16 Blogs to Help You Master the Business of Design

It’s important to be sure you understand how to grow your design business. I’ve compiled several of the best blogs talking about the business of design.

40+ Abstract Art Wallpapers, Digital Art Wallpapers, Colorful Wallpapers | Free Download

Download Abstract Art Wallpapers for your desktop screen.

Java Seven Make Developers Most Productive

Each JAVA packages comes with some most helpful techniques for developers.Apart from all other packages, java 7 promises new features like modularization, developer productivity tools

20 Fonts made popular by or inspired by Movies and Brands

If you’re a movie fan I am sure you’ll enjoy this collection of 20 beautiful movie/brand fonts. All these are free and I think they should be part of any designer’s font library.

35 Beautiful & High Quality UI Icon Sets

I have compiled a list of 35 high quality and beautiful icon sets that would be a great addition to anyone’s arsenal.

iPhone-Style Navigation:AJAX + Rotate (Part II)

This is the sequel of previous tutorial discussing how to make iPhone style navigation. Once I promised to talk about how to implement AJAX and how to add cookie onto the script we have made before.

Codeigniter shopping cart v1.1 Part 10: Front page

Today we will work on a webshop controller and its’ views. This module controls all the front-end functions. I will cover the front page in this article. The goals for the front page are the …

CSS3 Tutorial – Website-Navigation based on Border-Radius

This Step-by-Step Navigation-Tutorial is made by CSS3-Properties like Border-Radius. This CSS3-Tutorial demonstrates how easy it can be to get attention to your navigation without any images!

Logo usage #7: Electronics

The area of electronics brands is so wide and deep that I could easily name this article Volume 1. But then again, I think that it would all get extremely boring til the moment we do…

Fish Eye Dock Style Menus

Here are 7 great dock styled plugins and tutorials that will allow you to add your own dock to your website or project, and give your project that extra bit of bling.

CSS3 Tutorial – Website-Navigation based on Border-Radius

This Step-by-Step Navigation-Tutorial is made by CSS3-Properties like Border-Radius. This CSS3-Tutorial demonstrates how easy it can be to get attention to your navigation without any images!

A Collection Of Damask Patterns

Damask has enjoyed something of a mini revival in recent months, this design style is very ornate and highly decorative.

500 Business Card Giveaway from UPrinting

We are very happy to announce that we are staring our second giveaway for our readers. UPrinting have offered to give both-sided, full color 500 business card for the readers of metamags.com.

20+ Exceptional Online Professional Image Editors and Drawing Applications

Here are the list of some popular and Professional Image Editors And Drawing Applications that work online.

20 Shots: Long Exposure Photography Examples

Everybody can find something interesting and unique in the process of doing long exposure shots and outcome sometimes surprises yourself.

20 Best PSD to HTML Service Providers

Converting design files (PSD, PNG, AI etc) to high quality, cross-browser compatible valid top-notch XHTML/ CSS semantic markup manually has never been easy, as it takes lot of time and precision

23+ Crazy Funny Cubicle Pranks

Designers be aware: Just when you thought it was safe to leave your desk or office, think twice. Cause this could happen to you…

FlashMoto Introduces the Multilingual Flash CMS!

FlashMoto is excited to announce the launch of the renewed Multilingual Flash CMS. FlashMoto Control Panel interface has been translated into 12 languages.

10 Best PSD to Drupal Theme Service Providers

CMS(s) provide the ease to operate and manage your website and this is the reason why there are so many content management systems smearing the internet

10 Amazing CSS3 Tutorials and Techiques for Creating Buttons

This is a collection of tutorials about CSS3 button . CSS3 has been in effect despite last year. Yet support for browsers running very slowly.

10 Useful Typography Tools for Designers

Have a look at these 10 useful typography tools sites and let us know your thoughts in comment.

Competitive Intelligence – Data Acquisition and Analysis

You may control all aspects of your website but there are numerous factors beyond site optimization and measurement that impact your revenue directly.

FlashMoto Introduces the Multilingual Flash CMS!

FlashMoto is excited to announce the launch of the renewed Multilingual Flash CMS. FlashMoto Control Panel interface has been translated into 12 languages.

Drupal Themes

Drupal 6.x Themes.Over 30 categories. All templates are user friendly and easy to edit.

150+ Free Paper Textures for your Next Design

This 150+ Free Paper Textures for your Next Design post is basically a set of unique resources you don’t want to miss.

The 8 Best Forthcoming Web Design Conferences

Attending major web design conferences show potential clients that you take your work very seriously, that you are at the cutting edge of recent developments in your field.

38 Great Tutorials To Convert PSD To HTML/CSS

You designed your website or blog using Photoshop.Then what?Then the design you created must be converted and coded to become alive.This step is a little bit hard but don’t be afraid.

100 Fresh Creative Business Cards

A business card creates a physical connection and bond between you or your business and your customers. Most business cards are dull, boring, and don’t say much about the person

Nine Most Influential Mobile Trends of 2010

There is no denying that last year was the smartphone year, it was the dawn of Android, and at the same time we saw the mobile applications exploded while more buyers preferred ..

Glory: A Beautiful & Free WP Theme for Personal Blogs

Glory theme is Best Suited for Personal Blogs. It has a Fun & Fresh Design.

Freebie: Heart of the Unicorn Vector

This heraldry design finds its inspiration in the recently passed Valentine’s Day, and is freely available for use in both personal and commercial designs. I hope you enjoy it!

40 Free Professional Useful Icon Sets for Web Designers

Most of the websites in this era have really graphical and illustrator based icons which using in software applications as well, the demand for well-designed icons are too much..

3 GIMP Video Tutorial Downloads

Download Hull Design Online’s three top rated video tutorials for The GIMP. These tutorials will allow you to learn new tricks and optimise The GIMP for maximum productivity.

High Five Font – Exclusive Free Font Download

High Five Font is another free font exclusive for ImJustCreative, continuing the process of helping designers spread the word about their font creations. You can download High Five font for free below

35 Amazing Stationery Pack Designs

This post shows a showcase of 35 creative stationery designs for business cards, letterheads and compliments slips. Hope you like it!

9ish captcha solutions to make your web app impressive

Found some really helpful and good looking captcha solutions for you website integration. Thought to share so as to use them freely on your website.

Photography By Boris Ovini

Beautiful portrait photography by Boris Ovini talented fashion photographer, based in Canada, Ottawa, ON.

391 Nice Computer Icons From Icon Gab

A while ago, someone told me about icongab, a blog which provides so many icon set just like iconspedia & vistaicon. I amazed with their collections – they’re so beautiful.

Nine Most Influential Mobile Trends of 2010

There is no denying that last year was the smartphone year, it was the dawn of Android

35 Clever and Creative Billboard Advertising

creating unique outdoor Billboard in high traffic areas such as occupy roads. It is best way of targeting the audience and promoting your product in public.

The Tweek List, 2-19

Freelance Review’s favorite tweets of the week.

5 Free worn colored vintage picture frames

Today we are giving away 5 free worn colored vintage picture frames u can use in your designs, or to use as a frame for your pictures.

Awesome illustrations from the talented designer, Ricardo Gimenes

Ricardo is a graphic/web/motion designer and free lancer who spends most of his time creating awesome illustrations of popular websites.

Beautiful Wildlife Photography by Frtosi

Beautiful Wildlife Photography by Frtosi of various animals

Unique Tool For Nikon’s COOLPIX S70 Touch Camera

MRM Worldwide has joined with Nikon to form an online tool named the Nikon Virtual Touch Experience.

High Quality Green Textures, PSD, Brushes, Vectors, Tutorials and lots more

High Quality Green Textures, PSD, Brushes, Vectors, Tutorials and lots more

Create a Penguins Illustration Tutorial for Global Warming Cause

Global Warming is one of the biggest problems of the 21th century. Global Warming is changing our world and the way we live, it destroying habitats of animals. In this tutorial..

Create Simple A/B Tests In WordPress

A/B testing allows you to try multiple versions and find the one that works best for your goals.

61 Free Vector Apple Graphics

Feeling hungry? How about a fresh, juicy apple? Here is an incredible and delicious collection of 61 vector apple graphics…

Top 40 Authors Of The Famous Design Blogs

Today we’ve decided is to come up with an amazing list of the top 40 authors in the web design, web development and internet industry.

Top 20 Beautiful Websites

Here are my picks for the Top 20 Beautiful Websites based on visual artistry, integrated sound, ease of use, and pure uniqueness.

See full post here…