Wednesday, April 27, 2011

Allows a user to make page as homepage by only pushing a button

<script type="text/javascript">
function CreateBookmark()
{
var title = 'Visual Search';
var url = 'http://www.visual-search.net';
if(window.sidebar)
{
window.sidebar.addPanel(title, url,"");
}
else
if(window.external)
{
window.external.AddFavorite(url, title);
}
else
{
alert("The page could not be added to your favorites.");
}
}
script>

<input onclick="this.style.behavior='url(#default#homepage)'; this.setHomePage('http://www.visual-search.net');" type="button" value="Home Page"style="z-index: 102; left: 40px; position: absolute; top: 390px; width:100px; background-color:Yellow;" />

Monday, April 4, 2011

Multi Spaces should convert in to single space

public static string NormalizeWhiteSpace(string S)
{
string s = S.Trim();
bool iswhite = false;
int sLength = s.Length;
StringBuilder sb = new StringBuilder(sLength);
foreach (char c in s.ToCharArray())
{
if (Char.IsWhiteSpace(c))
{
if (iswhite)
{
continue;
}
else
{
sb.Append(" ");
iswhite = true;
}
}
else
{
sb.Append(c.ToString());
iswhite = false;
}
}
return sb.ToString();
}