Thursday, May 27, 2010

Open Source HTML Editor

TinyMCE is a very useful open source html editor. Thave have seperate version for .net, php, Coldfusion and JSP.
Visit: TinyMCE, or to Download it go to: TinyMCE | Get TinyMCE at SourceForge.net

Wednesday, May 26, 2010

Tuesday, May 25, 2010

Stop Words Removal using Windows 7 Training Kits

The following sample application is done using Windows 7 Taskbar APIs. Main features used are:
1. Status bar in the icon during processing
2. Thumbnail preview
2. Jumplist customization



Please email me at sunnyhasan at gmail dot com for the source code and more details.

Fix: "Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed"

Solution:

Step 1: Enable User Instances for SQL Server installation.


a. Go to Query Window in SQL Server Management Studio and type this:

exec sp_configure 'user instances enabled', 1.

b. Then type this: Reconfigure and run.

c. Restart the SQL Server.

Step 2. Deleting old old User Instances.

a. Go to the following path in your local machine and DELETE all files and folder under that folder:

C:\Documents and Settings\YOUR_USERNAME\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\SQLEXPRESS

Here, YOUR_USERNAME indicates the current username in your computer.

FIXing : "MSDTC on server 'servername' is unavailable"

Solution:

MSDTC service needs to be turned on in the server where the trigger resides. You can start this service in 2 ways:

1. Start the service from "Run": press ( Windows key+ R )and then type "net start msdtc" and press enter.

2. Go to START > SETTINGS > CONTROL PANEL > ADMINISTRATIVE TOOLS > SERVICES. Find the service called "Distributed Transaction Coordinator" and RIGHT CLICK on it and select Start.

Solving the issue of running MSDTC where the hosting service doesn't support it:
Godaddy.com doesn't support MSDTC in their shared hosting. But, if you want to deploy you web site to their server and you don't have the permission to start that service, the work around is using ";Enlist=false" at the end of your connectionString in webConfig file. For Example:

connectionString="Data Source=sunnyhasan.resource.com;Initial Catalog=sunnyhasan;User ID=sunnyhasan;Password=scars123;Enlist=false"

Saturday, May 8, 2010

url decode in MySQL

I got the following function from Garrett Hill. The following function is the same as urldecode($text) function in php. Garrett just saved my life.


--------------------------------------Function Starts--------------------------------

DELIMITER $$

DROP FUNCTION IF EXISTS `typing_wikipedia`.`url_decode`$$
CREATE FUNCTION `typing_wikipedia`.`url_decode`(original_text text) RETURNS text CHARSET latin1
BEGIN
declare new_text text default null;
declare pointer int default 1;

set new_text = replace(original_text,'+',' ');
while (LOCATE("%",new_text,pointer) <> 0 )&& (pointer < length(new_text)) do
set pointer = LOCATE("%",new_text,pointer);
set new_text = concat(left(new_text,pointer-1),char(conv(mid(new_text,pointer+1,2),16,10)),right(new_text,length(new_text)-(pointer+2)));
set pointer = pointer + 1;
end while;

return new_text;

END;

$$

DELIMITER ;

------------------------------------Function ends-------------------------------

Reference: MySQL Forge

Tuesday, May 4, 2010

How to use autocomplete extender in AJAX toolkit

Drag and drop a textbox in asp.net page and then wired your textbox with a autocomplete extender like below:

<div id="siteSearch">
<br />
<asp:TextBox ID="searchAutoCompleteTextBox" runat="server" CssClass="textBoxStyle"></asp:TextBox>
<div id="divwidth">
</div>
<ajaxControlToolkit:AutoCompleteExtender ID="searchAutoCompleteTextBox_AutoCompleteExtender"
runat="server" DelimiterCharacters="" Enabled="True" ServicePath="~/assets/services/autoComplete.asmx"
ServiceMethod="GetCompletionList" MinimumPrefixLength="1" EnableCaching="true"
TargetControlID="searchAutoCompleteTextBox" CompletionListCssClass="AutoExtender"
CompletionListItemCssClass="AutoExtenderList" CompletionListHighlightedItemCssClass="AutoExtenderHighlight"
CompletionListElementID="divwidth">
</ajaxControlToolkit:AutoCompleteExtender>
</div>


Then add a web service and with the following method. Please note that the return type, params should be same as the following otherwise the autocomplete will nto work. You can only change the name of the method name:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;

/// <summary>
/// Summary description for autoComplete
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class autoComplete : System.Web.Services.WebService {

public autoComplete () {

//Uncomment the following line if using designed components
//InitializeComponent();
}

[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] GetCompletionList(string prefixText, int count)
{
string[] suggestions = new string[10];

DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("~/App_Data/AcademicUnitHierarchy.xml"));
DataView collegeDV = ds.Tables[0].DefaultView;
collegeDV.RowFilter = "h2=0 and acad_status=0";
for (int i = 0; i < 10; i++)
{
suggestions[i] = collegeDV[i]["name"].ToString();
}
return suggestions;
}
}