blog.x-e.ro / code: page 6 of 38

graphic reset buttons

html-css :: w/o javascript

i was having some trouble at work creating form buttons with graphics for reset buttons. i just thought someone might be interested in my non-javascript solution:

<button style="background: none; border: none;">
<img src="reset.jpg" alt="" />
</button>

Read: graphic reset buttons »

post and querystring vars in dotnet

c-sharp :: asp.net c#

here's a nice little snip of c# code. this is meant to be used in an asp.net web application. the following code will return either a querystring variable or a post variable, it tries both and finds the valid one.

public string RequestParam(string paramname)
{
    string result = string.Empty;
    if (Context.Request.Form.Count != 0)
    {
        result = Convert.ToString(Context.Request.Form[paramname]);
    }
    else if (Context.Request.QueryString.Count != 0)
    {
        result = Convert.ToString(Context.Request.QueryString[paramname]);
    }
    return (result == null) ? string.Empty : result.Trim();
}

Read: post and querystring vars in dotnet »

random page perl script

perl :: CGI randomization

place this code in a file called index.cgi, chmod it to 775, and place it in a directory of html files. this script will pick one of the files in the specified directory at random, and print it to the screen. refresh the page for a new random one.

#!/usr/bin/perl
print "Content-type: text/html\n\n";
 
#print "<pre>";
$basep = "/wwwroot/path2/randomdir";
 
srand(time ^ $$);
#print "got random time...\n";
 
@files = `ls $basep/*.html`;
#print "got file list...\n";
#foreach (@files) { print "-----$_\n";}
 
$file = rand(@files);
#print "got random file...$phrase\n";
 
$nupath = "$files[$file]";
#print "got new path...$nupath\n";
 
open(LOG, $nupath) or die "$!\n"; 
while () 
{
  print $_;
}
close (LOG);
#print "</pre>";

exit;

Read: random page perl script »

loading...

loading...