Deprecated: Assigning the return value of new by reference is deprecated in /home/tryangle/public_html/blog/wp-includes/cache.php on line 36

Deprecated: Assigning the return value of new by reference is deprecated in /home/tryangle/public_html/blog/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /home/tryangle/public_html/blog/wp-includes/theme.php on line 507

Deprecated: Assigning the return value of new by reference is deprecated in /home/tryangle/public_html/blog/wp-content/plugins/codesnippet/codesnippet.php on line 248
Tryangled Dev » 2008 » September

Archive for September, 2008

Creating Images Dynamically

Tuesday, September 30th, 2008

Ask any ASP developer who has ever tried to dynamically create his own images and he?ll tell you it?s a nightmare. In fact, it?s more than a nightmare. It?s practically hell. The only true solution? Reverting to an expensive, dodgy, third-party control to do the work for you.

With ASP.NET, however, you can develop your own dynamic images with ease. Simply create an image object and use the new GDI+ features to add objects to that image, such as text, rectangles, and ellipses. After that, you can simply stream straight back down to the client.

But covering the graphics features in depth would require at least another two books, and, unfortunately, we don?t have that much room. So, I?m going to share a sample that demonstrates creating a small ?Drawing? button, alongside a little blue-and-yellow bullet point.It?s the sort of personalized graphic you?ll find on sites such as Amazon.com.

Posted by

Stopping Your User from Right-Clicking

Tuesday, September 30th, 2008

Want to prevent your user from performing any of the other commands available by right-clicking on a Web page in Internet Explorer? It?s not foolproof, but this neat little HTML edit usually does the trick.

Just alter the opening <body> tag of your HTML to the following:

<BODY oncontextmenu=”return false”>

When the menu is requested, the oncontextmenu event runs, and we instantly cancel it using JavaScript. This is especially potent as a method for stopping the user from viewing your source, when used in conjunction with a menu-less browser window. Great stuff!

Posted by

Smart navigation

Tuesday, September 30th, 2008

Smart navigation is a little-known Internet Explorer feature that enables the individual controls on your Web forms to maintain focus between postback, as well as allows you to suppress that flicker that occurs as you load the new page.
To turn on this little-known feature, simply set the smartNavigation property of your ASPX page to True. You can also apply the property to all project pages, by adding the <pages> tag to the following location within your Web.config file:

Note that smart navigation works on only Internet Explorer 5 and above; however, ASP.NET will automatically detect this and serve up the ?smart? code only if the target browser supports it.

Also, I?d personally advise that you test it against any third-party menu controls or scripts you may have running: it is prone to falling over on particularly advanced pages.

Posted by

What is the .htaccess File?

Monday, September 29th, 2008

To fully comprehend the .htaccess file and appreciate its usefulness, we first must discuss the main Apache configuration file, called httpd.conf. The httpd.conf file, known simply as the config file, is where the Apache web server’s configuration details are held, including modules, directives, port numbers and other values.. It resides on the administrator’s machine.

Every time an Apache-based web site is loaded, the httpd.conf file is consulted and interpreted. Whenever the file is modified, the administrator restarts (or bounces) the web server, which will compile the httpd.conf file again with the modifications intact.

However, when web servers are built to support outside clients, like a web hosting company’s web servers, administrators do not want clients to have access to the httpd.conf file. If they did, customers could inflict extreme damage on the server. However, at the same time, there are many utilities that customers should have the freedom to explore for their web site.

What is the solution? You guessed it, the .htaccess file. This file is merely an extension to the httpd.conf file; only this time, customers have access to it. Restrictions are placed on the .htaccess file to prevent customers from intentionally or inadvertently damaging default server configurations. Each time an Apache-based web page is loaded, the nearest .htaccess file is consulted and interpreted. The web server does not need to be restarted (or bounced) after each change of the .htaccess file. The file simply needs to be re-uploaded.

Since we now know a little about what the .htaccess file is and what it does, we can examine the magic of the file and look at some typical implementations.

Posted by

Enabling server-side includes

Monday, September 29th, 2008

*  Server-side includes are macros within HTML expanded on the fly
o Dynamically
o Conditionally
* Usage:

AddType text/html .shtml
AddHandler server-parsed .shtml

* See Apache’s Handler Use and mod_include documentation for more information.
* ITS has documentation on Server Side Includes at Monash

Posted by

Custom Error Documents

Monday, September 29th, 2008

*  Some sites establish site wide 404 error pages. For example:
There is a Characterology Default 404 error page.
* 404 handlers can be created by every web hosting user. They can even be put in every indivdual directory. For example:
Psychology Department’s Error Page
* Usage:

ErrorDocument 404 errors/404.html

Note: It’s probably better to start with a leading / so that this directive has a complete path specification to make sure that the 404 handler page can always be found.
* You can also have error documents created by CGI:

ErrorDocument 404 /psych/cgi-bin/error/error?404

* An example of the power of customized error documents is for telling people why their authentication failed

Posted by

.htaccess Format

Monday, September 29th, 2008

*  The dot in .htaccess makes it a ‘hidden’ Unix file. It is not listed in a normal directory listing. If default directory indexes are enabled on the web server, this file will be hidden in those lists also.
* It is a plain ASCII text file. It should be editted with an ASCII text editor like notepad.
* Comments are marked with a hash (#) at the start of the line.

# this is a commented-out line

* It needs to be readable by the server (’world’ readable), which can be a security problem.

Posted by

What can web hosting users do with .htaccess?

Sunday, September 28th, 2008

*  Specify custom error documents
* Add special document handlers and MIME types
* Set environment variables
* Redirect URLs from one to another
* Rewrite one URL into another
* Restrict documents to specific people

Posted by

What are .htaccess files anyway?

Sunday, September 28th, 2008

Simply put, they are invisible plain text files where one can store server directives. Server directives are anything you might put in an Apache config file (httpd.conf) or even a php.ini**, but unlike those “master” directive files, these .htaccess directives apply only to the folder in which the .htaccess file resides, and all the folders inside.

This ability to plant .htaccess files in any directory of our site allows us to set up a finely-grained tree of server directives, each subfolder inheriting properties from its parent, whilst at the same time adding to, or over-riding certain directives with its own .htaccess file. For instance, you could use .htacces to enable indexes all over your site, and then deny indexing in only certain subdirectories, or deny index listings site-wide, and allow indexing in certain subdirectories. One line in the .htaccess file in your root and your whole site is altered. From here on, I’ll probably refer to the main .htaccess in the root of your website as “the master .htaccess file”, or “main” .htaccess file.

There’s a small performance penalty for all this .htaccess file checking, but not noticeable, and you’ll find most of the time it’s just on and there’s nothing you can do about it anyway, so let’s make the most of it..

Posted by

Objects and Properties

Friday, September 26th, 2008

Your web page document is an object. Any table, form, button, image, or link on your page is also an object. Each object has certain properties (information about the object). For example, the background color of your document is written document.bgcolor. You would change the color of your page to red by writing the line:  document.bgcolor=”red”

The contents (or value) of a textbox named “password” in a form named “entryform” is document.entryform.password.value.

Methods

Most objects have a certain collection of things that they can do. Different objects can do different things, just as a door can open and close, while a light can turn on and off. A new document is opened with the method document.open() You can write “Hello World” into a document by typing document.write(”Hello World”) . open() and write() are both methods of the object: document.

Events
Events are how we trigger our functions to run. The easiest example is a button, whose definition includes the words onClick=”run_my_function()”. The onClick event, as its name implies, will run the function when the user clicks on the button. Other events include OnMouseOver, OnMouseOut, OnFocus, OnBlur, OnLoad, and OnUnload.

Posted by Mohamed Asif