Posts

Showing posts from 2009

how to remove Html tags from string in c#

I have tried to use the code from following blog to remove HTML tag http://aliraza.wordpress.com/2007/07/05/how-to-remove-html-tags-from-string-in-c/ It works very well for most tags. However, it will not remove the &nbsp and sometimes cause problem in my code.

Big Mistake using VS2008 Website publish

Today I made a terrible mistake by using VS2008 website publish tool and selecting to delete existing file during the upload. I assume VS2008 will only delete the duplicated files. Noop. VS2008 Deleted all the other folders in the target folder, which I have many sub domain and documents that I do not want VS2008 to delete... I have no where to get some of those file back. So bad....

C# equivalent of UnEscape funciton

In Javascript, I passed the value of FCKEditor to wbservice and stored it into database. However, the display of this value is through C#. Therefore I need to use Unescape from c# to display the value. The following article provides a detailed method to do this work. http://kseesharp.blogspot.com/2008/01/c-equivalent-of-javascript-escape.html

Integrate of FCK Editory

Start point: http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/Integration/ASP.NET First issue, do not forget to copy the FCKeditor to your project. Otherwise, after you add the control to your test page and start to debug, an error message will pop up. Second issue, after making the demo page work and start to type a few words, I noticed that there is a spell checker button. After I click this button, a dialog pop up with a license information. I need to remove this button. The following document provides way to customize tool bar. http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/Configuration/Toolbar Following settings set a customized toolbar FCKeditorV2:FCKeditor ID="FCKeditor1" runat="server" ToolbarSet ="MyToolbar" Height = "600px" FCKeditorV2:FCKeditor In my code, I have an existing text area to allow user to type product description. With following code I can quickly replace the textarea to FCKEditor. In Javascript of ...

Pay Per Play Web Site Down

Today I just read about Pay Per Play . It looks to be a great opportunity. I googled about it and some people say "Great", while others think it a scam. Well, I will try it myself before make a decision. First, I registered from Netaudio Adds , and then I did recieve a few email. How ever, when I followed the instruction in the email, this is what I get. ============================== Server error! The server encountered an internal error and was unable to complete your request. Error message: Premature end of script headers: a.cgi If you think this is a server error, please contact the webmaster. Error 500 sellingppp.com Thu May 7 21:46:51 2009 Apache/2.0.63 (FreeBSD) PHP/5.2.9 mod_ssl/2.0.63 OpenSSL/0.9.7e-p1 ============================= Any idea?

How to keep the format of user entered text

Image
It is not so easy to maintain the text format user enters in a text box in. The best way to do this is to make use of some existing rich text format. There are some discussion here : What rich text control for ASP.Net 2.0? The following is a quick method to keep some simple format. Formatting text in classic ASP . This article provides a quick method to do it using ASP. FCK Editor is the one that are used very widely. More details can be found from FCK Editor page . I have got some problem with using this control. Therefore, I am trying to find some good tutorial about how to integrate FCK editor with my website. The following article gave me a good start point. How to Integrate NetSpell with FCKEditor . I will try to follow this article and make it work for my website and upload the test site to my website hosted at www.GoDaddy.com .

Tool to transfer data among SQL Servers

Since I have no bulk read and write permission to my SQL Server database at my previous hosting plan, I can not use SQL Server data import/export tool to transfer my data to my new hosting database server. I spent a few nights and developed a small tool that connects to any sql server using OLE DB, fetch all tables in the database, and fetch all data from any table page by page. Based on this function, I have successfully implemented the tool to transfer any amount of data between two remote sql servers. The tool can not solve one problems so far. If any field is auto increase, the backup may not succeed. The project has been uploaded to popfly. SQLViewer

MachineKey and validation key configuration problem

I got the following error when I clicked a radio button on my web page after a couple of hours. This error only happens when the web page was loaded quite a little while ago and then you try to refresh it. It means that your post back request was sent to another machine of the web farm that has a different ValidationKey. ============ Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster. 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.Web.HttpException: Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be ...

Circular reference error in Object Serialization in Asp.Net using C#

Category object is a typical object that requires parent/children relationship. What's more, it is a common practice that the child object will require a parent object reference. When we use object serialization, it is very important that we set the parent object as [XmlIgnore]. Otherwise, the serialization will raise an exception as following: Circular reference was detected while serializing an object Categories. The following is the code sample. /// /// Summary description for Categories /// public class Categories { [XmlIgnore] public Categories m_parentCategory; public Guid m_CategoryID; public string m_CategoryName = ""; public short m_iLevel = 0; public static Categories rootCategory = null; public List m_oSubCategories = new List (); public void Save(string fileName) { FileStream fileStreamCreate = new FileStream(fileName, FileMode.Create); XmlSerializer serializerCategory = new XmlSerializer(typeof(Catego...

Shared ASP.NET project on Popfly

I have just created a demo project to navigate file structure in hosting environment, create/delete folder, create/delete xml file and RSS feed using ASP.NET and C#. The following is the webpage to get the popfly project. http://www.popfly.com/users/370203/WebSiteXML.details It is test on Visual Web Developer 2005 Exprss Edition.

Problem with MDB file in Asp.Net application

I have been using Microsoft Access database to store some infrequently changed information for quite some time. It worked well until recently I began to use GoDaddy Hosting plan. I uploaded my application to my GoDaddy hosting server, made some changes online, and downloaded to my local development environment because I noticed that the online change did not work as I expected. With some debug, I found that I got a strange exception with all update SQL statement. System.Data.OleDb.OleDbException was caught Message="Operation must use an updateable query." Source="Microsoft JET Database Engine" ErrorCode=-2147467259 StackTrace: at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Data.OleDb.OleDbCom...

Send Email using ASP.NET by GoDaddy mail server

After transferring to GoDaddy from another Hosting plan, one of the major changes I have to make is the email function. Luckily I have all my email functionality in one utility class. In this class I attempt to use both methods to send email. Actually both should work. private static void SendEmailOut(string sTo, string sSubject, string strMessageText) { try { SendMailByWebMail(sSubject, sTo, strMessageText); } catch (Exception ee) { try { SendEmailByNetMail(sSubject, sTo, strMessageText); } catch (Exception ee2) { throw (ee2); } } } //method 1 Webmail public static System.Web.Mail.MailMessage CreateMailMessage() { System.Web.Mail.MailMessage newMessage = new System.Web.Mail.MailMessage(); newMessage.From = "Technique Support "; newMessage.Headers.Add("Reply-To"...

Lost Website domain name

Unfornately I lost my website domain name. I forgot to renew the domain and the next day I noticed my domain had been registered by ICANN. Sigh... The good thing is that I have planned to shift my website from Hostdepartment to Godaddy and now it is definitely the good time to do it. The first thing is to get a good domain name. It took me quite some time to make a decision on this issue. Then I canceled my original Economy hosting plan and bought a deluxe hosting plan. With a coupon altogether it cost me 60$. After 12 hours or so I was able to upload my website to my new domain. During the setup I noticed that GoDaddy is using web farm to host the websites because I made use of Application variables in my ASP.NET website. From time to time the request will trigger a Application varible loading function. I wished I had used other techniques instead of Application varible to hold global values. Fortunately most of my website functions do not depends on application variables. Therefore I...

Meta data of webpage

Yesterday I noticed that the search result of my website was displayed terribly in Google search. After some search and comparison, I realized that I had not put any meta data like "Key Words", "Description" to my web pages. "Key Words" does not means too much to Google, so far as I can tell. However, description is quite important as it might be shown in Google search result. The following are office Google blog to discuss the importance of the meta data. Answering more popular picks: meta tags and web search . and The meta element Yahoo also provides a guide line to design the key words meta tag. How should I write my keywords? Based on the suggestions, I finally added description and keywords to my web pages dynamically based on the web page content. The following article provides a method to add meta data to Asp.Net web pages using C#. Adding Meta Tags to the Head in ASP.NET 2.0 You can find a complete discussion from following link: Are repeated meta...