SQL Server | Remove Special Characters

I needed to remove all the special characters from a field in a particular table in SQL Server to be used for searching purposes. After searching (binging :P)… I found the next SQL Server Function which did the trick.

This Function Removes any special character from the string value passed. All characters except 0-9, a-z and A-Z are all removed, whilst the remaining characters are returned back.

ALTER FUNCTION dbo.RemoveSpecialCharacters
(
@s VARCHAR(256)
)
RETURNS VARCHAR(256) WITH SCHEMABINDING

BEGIN
IF (@s is null)
RETURN null Continue reading

Set Negative and Zero Formatting in String.Format

Apart from setting the format you want the string to be shown, the format parameter in the String.Format method also allows to pass the negative formatting and zero formatting.

First is an example of the normal usage of this method:

String.Format(“{0:€ #,###.##}”, price);

To include the negative formatting add the following:

String.Format(“{0:€ #,###.##; (€ #,###.##)}”, price);

To include both the negative and zero formatting:

Continue reading

Shared Hosting | Unlimited Emails | Any Ideas?

Hmmm… I’m developing a website which will have a Newsletter Sender function to a list of emails… I’m seraching for a Shared Hosting which lets me send unlimited emails, or at least send about 2000 emails at one go. This will be used to send newsletters and email shots. Anyone has any idea if this type of hosting is available? And if yes which one?

Also someone told me to instead buy a VPS? Is it worth it for only one site?

Websites June Refresh :]

Deep Design Malta

Just updated my websites to be all showing the same theme.. to start the month of June in style 🙂 Previously they only had the logo but now made some touch ups and really hope you like them.

With these designs i’m trying to make an identity for my sites… following more or less the same design principles. For now they only have one page so there’s not much to see… but they are still much better than before 🙂

You can access my websites using the below links..

Deep Design is my main brand and is the one I use when developing websites for clients.

Ciappara.com is the new place that this blog will be moving to. It’s still being developed and will let you know when it’s ready.

Homes.com.mt is a new project that will be launching.. but i’ll have more details on this later 🙂

When I have more updates, I’ll let you know… btw hope you like the design 😉

If you have any comments or suggestions (which I too have many :]) please let me know.

Regards,

Clive Ciappara

Google Event Tracking Failing

Google Analytics Event Tracking

We’ve been using Google Analytics events tracking starting from this year and they are very useful. This week we noticed that website events weren’t being tracked, and haven’t been from the beginning of May.

After checking, everytime we tried to call the pageTracker._trackEvent method, it always returned fail. After searching and testing a bit, we noticed that apparently google made some changes to the trackEvent method.

Where before they allowed the optional_value (the last parameter if the method) to be a string or a number, now it is allowed to be a number only… thus the correct params would be:

pageTracker._trackEvent(‘my_category’, ‘my_action’, ‘my_optional_label’, 14);

Hope this helped some people 😉 It helped me 🙂

Reference: click here

Response.End()

Response End

This is added after the text needed in the response stream is written using the Response.Write() so no other html or garbage is written in the response stream.

Without response.end() javascript will have the text and the remaining garbage.

[ex. 1] without response.end()

Response.Write(“err”);
…..
result =”err

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” ><head><link href=”../App_Themes/Default/Content.css” type=”text/css” rel=”stylesheet” /><link href=”../App_Themes/Default/Default.css” type=”text/css” rel=”stylesheet” /><link href=”../App_Themes/Default/EmailSender.css” type=”text/css” rel=”stylesheet” /><link href=”../App_Themes/Default/Header.css” type=”text/css” rel=”stylesheet” /><link href=”../App_Themes/Default/Header2.css” type=”text/css” rel=”stylesheet” /><link href=”../App_Themes/Default/Sidebar.css” type=”text/css” rel=”stylesheet” /><title> </title></head><body>    <form name=”form1″ method=”post” action=”WebService.aspx” id=”form1″><div><input type=”hidden” name=”__VIEWSTATE” id=”__VIEWSTATE” value=”/wEPZwUPOGNjY2JiNjJiNWQ5MDI41In2qlnOWzD0wbpAPF80y1dPYTA=” /></div>
</form></body></html>” Continue reading

Reference Controls from MasterPage

To reference controls from a master page in a normal page use the following syntax:

Ex. Reference the Head Html tag of the Master Page from a normal page to add scripts in the head. Set the Head as runat=”server” and give id=”Head”, then enter the following syntax:

HtmlHead headTag = ((HtmlHead)((MasterPageName)this.Master).FindControl(“Head”));

Hope this helps. Btw this will mostly be used in Visual Studio 2005 since in the new versions, you can add an ContentPlaceHolder in the Head tag of the Master page and insert any scripts in the PlaceHolder on the page

ASP.Net Menu Control Problem with IE8

When loading a website that utilises the asp:menu control, in the development machine it works fine but on the server (in our case Windows Server 2003 R2) the menu isn’t shown correctly. Instead a blank panel would be viewed. As a temporary solution, the IE8 compatibility button can be clicked, but some styles might not work well with IE7 compatibility. So below please find the patch for asp:menu which can be applied to Windows or Windows Server, to build IE8-compatible ASP.NET WebForms sites…

Continue reading

Quickie | ‘Sys’ is undefined Solution

Today I was trying to call a web service from Java Script using the Sys.Net.WebServiceProxy.invoke function but the following error was loading:

‘Sys’ is undefined

The problem was because the ajax was not being referenced in the website. The solution I found was to create a new website in Visual Studio 2005 and use the AJAX Control Toolkit Web Site Template. When I ran the code again, no error was loaded and everything worked fine!