Monday, March 2, 2009

Restricting Text box (Multiline) using Javascript

//Restrict Length
function restrictLength(e,ctl,maxLength)
{
var evt = e ? e : window.event;

//check the length for copy paste
if (ctl.value.length >= maxLength)
{
//only character
if (e.keyCode == 0)
{
return false;
}
}
return true;
}
-- don't for get to called using (RETURN)
javascript:return restrictLength(event,this,10);

Sending Email from HTML

I decide to use File rather then web request coz some server are restricted to loopback.

///
/// Get Email Body from file
///

///
public static string GetEmailBodyFromFile(string filePath)
{
string emailMasterBody = "";

Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
using (System.IO.StreamReader objReader = new StreamReader(filePath, encode))
{
emailMasterBody = objReader.ReadToEnd();
}

return emailMasterBody;
}