Why, hello there! Nice of you to stop by!
I've figured out a few fun things in my studies, and I figure I may as well post them here, for your amusement. If you find something useful, cool! Maybe you could drop me a line, show me what you did?
Also, if you are a registered user, and have some fun stuff you want to share here, let me know!
And now for the fun stuff!
[#1] C# | Reseting control values in a Windows Form project
This little snippet will reset the text in every textbox and richtextbox control within the form. I also coded it to reset the value of a numericupdown control in my form. It is one of the better uses I've found for the foreach keyword...
foreach (Control ctrl in this.Controls)
{
if (ctrl is TextBox)
{
ctrl.ResetText();
}
if (ctrl is NumericUpDown)
{
ctrl.Text = "1";
}
if (ctrl is RichTextBox)
{
ctrl.ResetText();
}
}
[#2] Regular expressions | Pretty URLs
Hide the technology your site uses, and make your URLs easier to remember. Within your .htaccess file (provided your host lets you modify it), add:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\. { DOC TYPE HERE } -f
RewriteRule ^(.*)$ $1.{ DOC TYPE HERE }
Simply replace { DOC TYPE HERE }
with whatever you use: HTML, PHP, ASP, etc. Viola! Pretty URLs!
If this doesn't seem to work right away, you might need to add:
RewriteEngine ON
to the top of your .htaccess file.
Home
Blog
News
Geeky Bits
Archives
Gallery
News!
Blog!