Archive for the 'Programming' Category

Add Google Driving direction gadget to your webpage

Last week, I got an email from Google and was asked to test their new Google Driving Directions gadget on our newly re-design web site. If we like it and decide to use it on our web site, then they will mention our website as the feature user in this new gadget public release next month.

I went to their new gadget creator web site (link here), and found there are two basic setting categories. One for the Display setting, and the other is the Gadget Setting.

Continue reading ‘Add Google Driving direction gadget to your webpage’

Related posts

The problem with Microsoft VSS and Copy web in Visual Studio .net

Asp.NETWhen I am using the Copy Web command in the Microsoft Visual Studio .net 2005 to copy asp.net files from the local to the remote server, sometime I got error saying “Access denied” (BTW, to see the Error Log, you will have to scroll down and click the Log… button which might be invisible if you have a small screen).

To resolve this problem, you will have to logon to the remote server to make sure

  • The destination folder is opened with Write permission for the ASP.NET users
  • If you are replacing the files, please make sure the files are not READ ONLY on the remote server

The item #2 happened to me a lot, and I had to uncheck the READ ONLY checkbox from the files’ properties. The only explanation I can come up is that the Microsoft Visual Safe 6.0 sometime made the files READ-ONLY since we are using VSS for the coding collaboration.

Related posts

How to set the DefaultButton in a Page Based on ASP.NET Master Page

Challenges:

Asp.NETAs I mentioned in my previous post, I fixed the issue of hitting enter key on an ASP.NET page with a single textbox and submit button. But now new issue occurred: I could not use the Enter key on other button web controls. Whenever I hit the Enter key in the web form, the onClick event of the search button fires not the other submit buttons. I know I am Master page and the search button has been included in every page based on this master page, and the search button is in the first button web control position.

Trouble Shootings:

OK, the first thing came to my mind to resolve the issue above was to use the  new DefaultButton properties in ASP.NET 2.0 form or panel controls. But since I am using Masterpage, when I put defaultButton=”btnSubmit” in master page or put the following code in my Page_load event

Page.Form.DefaultButton = “btnSubmit”

I got the following error:

Server Error in ‘/MyApplication’ Application.
The DefaultButton of ‘form1′ must be the ID of a control of type IButtonControl.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The DefaultButton of ‘form1′ must be the ID of a control of type IButtonControl.

Continue reading ‘How to set the DefaultButton in a Page Based on ASP.NET Master Page’

Related posts

How to fire onClick event with hitting Enter in ASP.NET forms

Challenge:

Asp.NETI have a search box in every asp.net web page with one text box and one submit button. When the visitor clicks the submit button, he will be re-directed to a search result web page since the onClick event is fired on that submit button. But when the visitor finishes his typing and simply hits the enter key, a postback event will be fired on the page level but the onClick event of that submit button could be not fired.

Solutions

After reviewing the HTML codes and HTTP requests, I found out the pair of button name/value has not been sent to the form along with the text box. That was the reason why the page could not decide whether the submit button triggered then not fired the onClick event.

I am using ASP.NET 2.0 and experiencing such issue, and not sure whether ASP.NET 3.5 still have the same issue. But a simple work-around can fix this issue - which is to add one more textbox web control.

For example, if you only have one textbox and submit button, the query string post back to the server will be

default.aspx?txtBOX1=some+value&

But if you have more than one text boxes in your asp.net page, then your string will be

default.aspx?txtBOX1=some+value&txtBOX2=some+value…btnSubmit=Search…

Of course, you do not want the visitors to see your addtional textbox, you should use a style to hide it. Do not use visibility property since that will disable that textbox web control. So your new textbox will look like the below

<asp:TextBox ID=”txtInvisible” runat=”server” Style=”visibility: hidden; display: none;” />

In this way, when the visitor express the Enter key, your first button web control will be fired.

[update: if you have multiple button web controls and want to control which one to be fired while the visitor hits the Enter key, please read on my next post]

Related posts

How to use XML Sitemap plug-in with WordPress MU

A couple months ago, I wrote a blog post in my Chinese blog about my own experience of configuring XML SiteMap plugin in the WordPress MU. It turned out that a lot of MU owners had the same problem before. So I decided to re-write it in English and share with you here.

I guess you should be familiar what the Google SiteMap is if you would like to increase your website/blog’s rank in search result. And you are using WordPress as your blogging platform, you might be interested in a plug-in called Google (XML) Sitemaps Generator for WordPress, which can allow you to easily generate Google XML SiteMap within your blog. But unfortunately the XML Sitemaps Generator (version 3.0.3) I used was not developed for WordPress MU. By default, it could only generate the XML sitemap for the primary blog not all other blogs in your WordPress MU.

Well, you can try your lucks on the author’s website to see whether he/she released a newer version to resolve the issue, or you can do it yourself by changing a few lines of code as I shared below.

Continue reading ‘How to use XML Sitemap plug-in with WordPress MU’

Related posts

How to export and import MySql database

image I have tried to re-configure the old web site log analyst tools - LiveStats XSP 6.2 for a long, long time. Finally I decided to wipe all of them and re-install again. To be safe, I have to back-up all MySql data (installed by LiveStats) first. Since the server is a Windows 2000, and I could not use web interface like Phpmyadmin. Well, I can copy all *.MYD files. But I found a better way by using the the following commands came with MySQL installation.
Continue reading ‘How to export and import MySql database’

Related posts

Is the Read-Only attribute on OS Oracle data file a bug for Oracle 10g?

In today’s Oracle 10g training, we were asked to do a exercise on tablespace. I needed to make a tablespace Read Only and Read Write. The syntax was simple, just “ALTER TABLESPACE tbs READ ONLY (READ WRITE”. But while I was playing around, I thought what would happen on the data file after I turned on the Read Only with the tablespace. So I checked the data file (like c:\oracle\oradata\something.dbf) and found out it did not have Read-only attribute even after I altered the tablespace as Read Only. Interesting, it seems the Oracle did not look up the OS level when it deals with the tablespace read-only attributes.

To make things more interesting, I turned on the Read-Only attribute for this tablespace’s data file (Right Click, and check the Read-Only in the proprieties window). Then I went ahead to make more alterations on the tablespace, like increasing the extents size etc. The funny thing was I could see these system changes in Oracle through some dba_ views, but actually they did not take effective. Since I could not insert any new record to a full tablespace even I “successfully” increase the size in Oracle.

Not sure Oracle already aware this situation or not.

Related posts

How to display 0 in conditional [group by] report in Count() SQL Query

sql-injection-database Challenge:
Let me assume this: we have two tables, one is Regions table with all region information (East, West, etc. ) and we have another table with Sales information. Now, we need to display a report with region information and how many sales conducted in each region with greater than $1000 value in each sale. It sounds simple at the beginning since a Count(*) with Group By can do this trick.

But what if I need to still show the region which does not have any sales greater than $1000 on the report? Using Count(*) itself in the query, the region without any sales greater than $1000 will not show in the query result, period.

Continue reading ‘How to display 0 in conditional [group by] report in Count() SQL Query’

Related posts

How easily to create a required validator requiredfieldvalidator for CheckBox control in asp.net 2.0

Challenge:

Asp.NET I tried to add a CheckBox control to the registration page in my newly implemented open source YetAnotherForum asp.net application. And this CheckBox is for Terms and Conditions agreement, so it needs to be checked before the users submit registration form. It looked like the easy way was to use a RequiredFieldValidator to validate the CheckBox control. But unfortunately this RequiredFieldValidator validation Web control does not work with the CheckBox (or CheckBoxList) Web controls. After I set its ControlToValidate property to the ID of the CheckBox, the page threw an HttpException, saying:

"Control ‘controlID’ referenced by the ControlToValidate property of ‘validationControlID’ cannot be validated." 

Ok, I can perform the validation check in the postback code or replace the RequiredFieldValidator with CustomValidator control. But this is for a constantly updated open source application, I did not want to change too much source code in case I will get overwritten in the next release. So, I need a quick and dirty way to do this.

Continue reading ‘How easily to create a required validator requiredfieldvalidator for CheckBox control in asp.net 2.0′

Related posts

How to remote connect to Microsoft SQL Server Express 2005

Challenge: By default, the SQL Server Express 2005 was not installed for remote access. Which means networking protocols are disabled by default in SQL Server Express. Thus, if you simply installed Express and chose all the defaults like I did, SQL Server Express will only be able to have connections originating on the local machine where SQL Server is installed.

That is why I got the following error message when I tried to connect to one SQL Server Express instance installed on another server from my desktop’s SQL Server Management Studio Express.

An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (Microsoft SQL Server, Error: -1)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=-1&LinkId=20476

And this is the screen shot I have.

sql_remote_error

Continue reading ‘How to remote connect to Microsoft SQL Server Express 2005′

Related posts

Fix a bug in YetAnotherForum version 1.9.1.8

YetAnotherForumAs my previous post said, I installed Yet Another Forum v1.9.1.8 on my server, then I created a board/forum. In my first and only one forum, I turned on the moderate mode which means that any post topic will not show till the forum administrator approves.

Then I went ahead to create the first new topic, and later on a few replied have been posted. Everything was fine but a few days ago the front page could not be seen. I tried a couple of times, only saw the error messages (There has been a serious error loading the forum. No futher information is available…) as the following screen shot. And funny thing was I still could access to other web pages include the administrative portion.

Error Message

Continue reading ‘Fix a bug in YetAnotherForum version 1.9.1.8′

Related posts

Get FCKeditor work on Oscommerce 2.2 release 2a

OSCommerceToday I downloaded All In One FCK Editor WYSIWYG Editor Oscommerce add-ons since I needed to add a WYSIWYG(What You See Is What You Get) HTML editor on one of my client’s Oscommerce Shopping Cart site.

After I did all uploadings and changes according to the Readme document, I got the following errors after I refreshed the back-end page.

Warning: Failed opening ‘fckeditor_php4.php’ for inclusion (include_path=”) in /var/www/html/catalog/admin/fckeditor/fckeditor.php on line 75

Continue reading ‘Get FCKeditor work on Oscommerce 2.2 release 2a’

Related posts

Fix wp.getusersblogs error in Windows Live Writer after upgrading to WordPress MU 1.5.1

I have been using Microsoft Windows Live Writer to update my blogs for a while, but today I got some errors when I tried to publish a post to my newly upgraded WordPress MU 1.5.1 blog. After this error message, I got a prompt windows to ask my blog logon user name and password. I thought the upgrading changed the user information anyhow, so that I updated my logon password, and re-typed it in Live Writer. When I re-published, again saw the same error. I stopped, and then tried to view the web blog within the WLW. The same wp.getusersblogs error popped-up as I encountered during the publishing.

The following is the detailed error message:

log Server Error - Server Error -32601 Occurred server error. requested method wp.getUsersBlogs does not exist. You must correct this error before proceeding.

Continue reading ‘Fix wp.getusersblogs error in Windows Live Writer after upgrading to WordPress MU 1.5.1′

Related posts

Can not start a workflow from a survey response in Windows SharePoint Services 3.0 (MOSS 2007) with "Failed to Start" error

Challenge:

sharepoint When I was approached by a co-worker to come up a quick solution to design a training registration application. The requirement is to display all upcoming training events in calendar view and allow users to register to each training. And upon the registration is submitted, the training department and the user’s supervisor should receive notifications immediately (although not required now, but might need the approval from the supervisor in later development). The deadline is very…, how to say it, … how about this afternoon. Well, while the co-worker asked how to design the database tables and asp.net coding, I suggested why not giving the SharePoint a shot. Since I am the one proposed, then I had to create it for her.

Well, that was what I came up so far. In our Microsoft Office SharePoint Server System (MOSS) 2007 with Windows SharePoint Services 3.0 (WSS), I created a calendar list to display training events; in the calendar item there was a link to another new created survey list acting as a registration form. Then I added a workflow to the survey so that emails will be sent out whenever a new response is added into the survey (or register list).

Everything is working fine, but however, the workflow does not start. Instead, the status of the workflow appears as Failed to Start.

Trouble-Shootings:

I searched this issue on Google, and I found out a lot of people had the similar errors before. Someone pointed out the cause was the user of application pool who should be Network Services instead of a user with administrative right; Someone suggested to re-active the workflow feature in SharePoint Application server; Someone asked whether it was done in SharePoint Designer  2007.

Continue reading ‘Can not start a workflow from a survey response in Windows SharePoint Services 3.0 (MOSS 2007) with "Failed to Start" error’

Related posts