A good article on styling forms using CSS can be found at aplus. A pity that not all browsers are not as good at CSS as they could be, if they were you could design forms without using tables.
Friday, July 30, 2004
ASP.NET Custom Controls
Excentrics World has a lot of free .NET Custom Controls for use on your ASP.NET pages. They are as follows:
- Accordion Panel
- Bread Crumb Trail
- Calendar Popup
- Collapsable Panel
- Empty DataGrid
- Faq Repeater
- Masked Textbox
- Multi-Text List Controls
- Numeric Box
- Ordered Listbox
- Time Picker
The source code is available for purchase (as download does not contain it).
Developing ASP.NET Server Controls on MSDN is a good article on creating custom controls.
The Regulator (Regular Expression Tool)
The Regulator is a tool for regular expressions. It integrates with RegExLib.com (regular expression library), by offering the ability to search it and submit your own regular expressions. You can also compile it to a .NET assembly or generate VB.NET/C# code so you can use throughout multiple projects.
Thursday, July 22, 2004
Url Manipulation (C#)
Edit (25-Mar-2005): Newer version here: Url Manipulation v2 (C#).
This class enables you to manipulate and get the QueryString of a page. It also returns the current page's AbsoluteUri (i.e. /path/to/myfile.aspx?param=test), base Url (i.e. /path/to/myfile.aspx) and virtual folder (i.e. /path/to/)
Use:
UrlQuery MyQuery;
private void Page_Load(object sender, EventArgs e) {
MyQuery = new UrlQuery("/path/to/myfile.aspx?param=test");
// or to get the current page use:
// MyQuery = new UrlQuery()
Trace.Write(MyQuery.Url); // returns '/path/to/file.aspx'
Trace.Write(MyQuery.VirtualFolder); // returns '/path/to/'
Trace.Write(MyQuery.Get()); // returns '?param=test'
// change query
MyQuery.Set("param2","value2");
Trace.Write(MyQuery.Get()); // returns '?param=test¶m2=value2'
// remove 'param' paramater
MyQuery.Set("param",null);
Trace.Write(MyQuery.Get("param2")); // returns 'value2'
Trace.Write(MyQuery.AbsoluteUri);
// go to new page
Trace.Write(MyQuery.VirtualFolder + "file2.aspx" + MyQuery.Get()); // returns '/path/to/file2.aspx?param2=value2'
}
The class 'MyQuery' is based on:
public class UrlQuery
{
/// <summary>
/// Base on current page
/// </summary>
public UrlQuery()
{
url = HttpContext.Current.Request.Url.AbsolutePath;
}
/// <summary>
/// Base on other page
/// </summary>
/// <param name="value">The url of the page to reference, i.e.: '/path/to/folder/page.aspx?param1=1¶m2=2'</param>
public UrlQuery(string value)
{
int q = value.IndexOf('?');
if (q != -1)
{
url = value.Substring(0, q);
queryString = NameValueCollection(value);
}
else
{
url = value;
}
}
private string url;
/// <summary>
/// The Url of the page, without QueryString
/// </summary>
/// <value>/path/to/folder/page.aspx</value>
public string Url
{
get
{
return url;
}
}
/// <summary>
/// Returns the virtual folder the page is in
/// </summary>
/// <value>/path/to/folder/</value>
public string VirtualFolder
{
get
{
return Url.Substring(0, Url.LastIndexOf("/") + 1);
}
}
/// <summary>
/// The AbsoluteUri
/// </summary>
/// <value>page.aspx?param1=1¶m2=2</value>
public string AbsoluteUri
{
get
{
return Url + Get();
}
}
private NameValueCollection queryString;
/// <summary>
/// Get the QueryString for the page
/// </summary>
public NameValueCollection QueryString
{
get
{
if (queryString != null)
{
return queryString;
}
else
{
queryString = new NameValueCollection(HttpContext.Current.Request.QueryString);
return queryString;
}
}
}
/// <summary>
/// Get the QueryString
/// </summary>
/// <returns>String in the format ?param1=1¶m2=2</returns>
public string Get()
{
string query = "";
if (QueryString.Count != 0)
{
query = "?";
for (int i = 0; i <= QueryString.Count - 1; i++)
{
if (i != 0)
{
query += "&";
}
query += QueryString.GetKey(i) + "=" + QueryString.Get(i);
}
}
return query;
}
/// <summary>
/// Get parameter from QueryString
/// </summary>
/// <param name="param">Parameter to get</param>
/// <returns>Parameter Value</returns>
public string Get(string param)
{
return QueryString[param];
}
/// <summary>
/// Set QueryString parameter
/// </summary>
/// <param name="param">Parameter to set</param>
/// <param name="value">Value of parameter</param>
public void Set(string param, string value)
{
if (param != string.Empty)
{
if (value == string.Empty || value == null)
{
QueryString.Remove(param);
}
else
{
QueryString[param] = value;
}
}
}
/// <summary>
/// Convert QueryString string to NameValueCollection
/// http://groups.google.co.uk/groups?hl=en&lr=&ie=UTF-8&safe=off&selm=uyMZ2oaZDHA.652%40tk2msftngp13.phx.gbl
/// </summary>
public static NameValueCollection NameValueCollection(string qs)
{
NameValueCollection nvc = new NameValueCollection();
//strip string data before the question mark
qs = qs.IndexOf('?') > 0 ? qs.Remove(0, qs.IndexOf('?') + 1) : qs;
Array sqarr = qs.Split("&".ToCharArray());
for (int i = 0; i < sqarr.Length; i++)
{
string[] pairs = sqarr.GetValue(i).ToString().Split("=".ToCharArray());
nvc.Add(pairs[0], pairs[1]);
}
return nvc;
}
/// <summary>
/// Copies a form paramater to the QueryString
/// </summary>
/// <param name="param">Form Parameter</param>
public void FormToQuery(string param)
{
this.Set(param, HttpContext.Current.Request.Form[param]);
}
}
Edit (25-Jul-2004): can pass on page url as a parameter (leave blank for current page)
Edit (27-Jul-2004): can copy a form elements value to the QueryString on postback. i.e.
void Button1_Click(object sender, EventArgs e)
{
// transfer form parameter to query
MyQuery.FormToQuery("mytextbox");
Trace.Write(MyQuery.Get());
}
Tags: CSharp, Web Developer Blog, ASP.NET
Wednesday, July 21, 2004
Programmers Notepad
A new build of programmers notepad is available - PN2 version 0.5.5 (herbie). Looks quite good and can only get better. Quite a few changes and bug fixes since 0.5 (the last development release) - including 'magic folders' within a project (a magic folder lists the files/folders contained within a directory on your computer). Read the release notes, or download from SourceForge.
I'm sure PN2 will be very good when the stable build is released.
Tuesday, July 20, 2004
Programmers Fonts
These fonts are quite good for when you work with source code and want a nice readable font:
Sunday, July 04, 2004
New MyGeneration Template Library
MyGeneration now has a new template library where you can add your own templates. Hopefully there will be many quality templates put on the site. Several of my templates have gone on (user sbc).


