How to load a different user control 

No Comments

You can clear out the contents of an old control and load in a new one, as needed.

Dim oldControl As UserControl = Master.FindControl(”oldControl”)
oldControl .Controls.Clear()
Dim newControl As Control = LoadControl(”~/controls/newControl.ascx”)
oldControl.Controls.Add(newControl)

Convenient Debugging 

No Comments

The For…Each loop gives you a convenient way to check on the field names and values that are submitted with a form and placed in the Request.Form Collection. You can place the following script at the top of your form page and it will report the field names and values that are transmitted to the server when you submit the form.

For Each Item in Request.Form
Response.Write(Item & ” = ” & Request.Form(Item) & ”
“)
Next

The output,

FieldName1 = Value1
FieldName2 = Value2
FieldName3 = Value3

appears at the top of your browser display so that you can check to make sure that what arrives at the server are the names and values that you thought were submitted with the form. This is a handly debugging script to use when you encounter problems in processing form information.

Browsing the Log History of a SVN Rep 

No Comments

You can quickly browse the log history of a SVN repository by using the following command:

svn log -r 1:10 -v

That will browse revisions 1 to 10 showing you all the files.

Permission Issues when Committing on Subversion 

1 Comment

I just setup a new subversion server, but I couldn’t get any of my clients to commit or import new data into the repository. The clients were getting the error message:

svn: Commit failed (details follow):
svn: Can’t create directory ‘/svn/repos/project/db/transactions/1-1.txn’: Permission denied

And the error logs gave me the error:

[Wed Feb 21 15:33:14 2007] [error] [client 10.0.0.1] Could not create activity /project/!svn/act/9daeeb55-032a-0410-afe1-c75d3611fb5b. [500, #0]
[Wed Feb 21 15:33:14 2007] [error] [client 10.0.0.1] could not begin a transaction [500, #13]
[Wed Feb 21 15:33:14 2007] [error] [client 10.0.0.1] Can’t create directory ‘/svn/repos/project/db/transactions/1-1.txn’: Permission denied [500, #13]

All of the websites referred to making sure the ‘apache’ user had ownership of the repository files, so the server could write the files. I had already done this, but it still wouldn’t write to the server. Then I found the following details at http://subversion.tigris.org/faq.html#reposperms

Note for SELinux / Fedora Core 3+ / Red Hat Enterprise users:

In addition to regular Unix permissions, under SELinux every file, directory, process, etc. has a ’security context’. When a process attempts to access a file, besides checking the Unix permissions the system also checks to see if the security context of the process is compatible with the security context of the file.

Fedora Core 3, among other systems, comes with SELinux installed by default, configured so that Apache runs in a fairly restricted security context. To run Subversion under Apache, you have to set the security context of the repository to allow Apache access (or turn off the restrictions on Apache, if you think all this is overkill). The chcon command is used to set the security context of files (similarly to how the chmod sets the traditional Unix permissions). For example, one user had to issue this command

$ chcon -R -h -t httpd_sys_content_t PATH_TO_REPOSITORY

to set the security context to be able to successfully access the repository.

Now everything works great.

File Permssion Errors in Plesk 8.1 on Windows 

No Comments

Just had to troubleshoot an issue on a Windows IIS Webserver where PHP didn’t have the proper permissions to write files.  The server is running plesk, so I had to determine which user is attempting to write the files.  It ended up being:

Plesk IIS User and Plesk IIS WP User

Giving them write permissions allowed me to upload and update files using PHP.

FCKEditor and new EnterMode & ShiftMode handling 

No Comments

A new version of the FCKEditor was released, version 2.4, which is a web based WYSIWG editor that you can embed into web forms. It allows for greater control of the content. The latest version added a new Enter Key Handler, here is the description:

The new Enter Key Handler, guarantees that the editor will behave in the way you want when users hit the enter key. You can configure it to produce, or tags, and all browsers will behave in the same way.

This Enter Key Handler is set in your fckconfig.js file, the FCKEditor config file. Look for the following lines

FCKConfig.EnterMode = 'p' ;            // p | div | br
FCKConfig.ShiftEnterMode = 'br' ;     // p | div | br

I personally set both modes to ‘br’. It avoids strange margin issues between various tags and appears to give the user the experience they expect.

Name ‘response’ is not declared. 

No Comments

When you attempt to use Response.Write in .Net, sometimes you need to use the full namespace to get it working. Simply use the following:

System.Web.HttpContext.Current.Response.Write(”Text that will be outputed”)

Also, when you attempt to use Rquest.QueryString() in .Net, sometimes you need to use the full namespace to get it working. Simply use the following:

System.Web.HttpContext.Current.Request.QueryString(”variable”)

UPS Shipping Calculation Changed 

No Comments

Recently, UPS made changes to their web services.  Now ‘Warnings’ are reported as errors.  This is causing many shopping carts to fail when calculating shipping costs.  I had a shopping cart that was getting Error #110971:  Your invoice may vary from the displayed reference rates.

Simply watch for that particular error and make the adjustments and you should be fine.

Creating PDFs with PDFCreator 

Comments Off

It’s a common headache. As a web developer, you have a client who wants to distribute Word and Excel documents on their website. You explain that it’s not best practice for visitors to download your Office documents, they should instead distribute PDF’s. But Adobe Acrobat is $300, which the client won’t spend. So they continue to upload Word & Excel files.

This headache can be remedied by having them download the GPL Licensed PDFCreator. It’s a perfect alternative to Adobe Acrobat for the client that wants to make simple PDF’s and it will not cost the client anything. You can find out more details at Newsforge.

| PDFCreator |

Quick Tip Using Zip in Linux and Windows 

Comments Off

To package and compress files, I use the zip software included in Linux. It gets the job done and works great. When using Windows, I install Cygwin and use zip instead of Winzip. It’s a great tool and saves me money.

Here is the command that I run to compress files:

zip -r ZIP_FILENAME.zip original_directory_name

Read the rest of this entry »