Monday, August 3, 2009

Jquery AJAX impacted on document.write

just find a solution, when you use jquery ajax, and there is document.write after that, it will clear all your content..

all u need to do is create a span, where you want to write that content. then.. overwrite document.write function to write into that span instead doing document.write..

here is the sample

span id="test" /span
script document.write = function(text){ jQuery('#test').append(text) }
/script


=D
Here is the reference
http://javascript.about.com/library/blwrite.htm


--------
Huh.. but this still have a problem.. in IE.. if you overwrite into different holder.

so the best solution at this moment is using iframe...

Sunday, May 10, 2009

Change culture without changing deployment Server

Add globalization tag inside System.web tag in Web.Config

globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="en-AU"

Wednesday, April 1, 2009

1st NHibernate.LINQ Limitation

Just found Nhibernate Linq limitation.

It can't translate toLower() on string but luckily, it has compare in case sensitive.

it throws weird error if you use this.
q = q.Where(c => c.firstName.Contains(flter) || c.lastName.Contains(flter) || c.email.Contains(flter));

says
----
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
----

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;
}

Tuesday, December 2, 2008

PL-SQL Looping

DECLARE CursorTemplate CURSOR
FAST_FORWARD FOR
SELECT Val1, Val2, Val3 FROM Table1

OPEN CursorTemplate

FETCH NEXT FROM CursorTemplate
INTO @Var1, @Var2, @Var3

WHILE (@@FETCH_STATUS = 0)
BEGIN
--do something here w/ your data

FETCH NEXT FROM CursorTemplate
INTO @Var1, @Var2, @Var3

END

CLOSE CursorTemplate
DEALLOCATE CursorTemplate

Wednesday, November 26, 2008

Fix Calendar Extender on IE 6

add this style
.ajax__calendar_container { z-index : 1004 ; }

add this javascript
function dateEditor_OnShown(dateControl, emptyEventArgs)
{
var shimWidth = dateControl._width;
var shimHeight = dateControl._height;

// Open current popup
// Create the popup element
var dateEditorShim;
dateEditorShim = document.getElementById("dateEditorShim");
dateEditorShim.style.width = dateControl._popupDiv.offsetWidth;
dateEditorShim.style.height = dateControl._popupDiv.offsetHeight;
dateEditorShim.style.top = dateControl._popupDiv.style.top;
dateEditorShim.style.left = dateControl._popupDiv.style.left;
dateControl._popupDiv.style.zIndex = 999;
dateEditorShim.style.zIndex = 998;
dateEditorShim.style.display = "block";

}

// Function: dateEditor_OnShown
// Summary: Handles the OnShown event of the dateEditor control.
// Inputs: dateControl -> The date control object
// emptyEventArgs -> Empty event arguments raised by the date control
// Remarks: Make sure to insert a shim of an empty iframe underneath the calendar popup container
function dateEditor_OnHiding(dateControl, emptyEventArgs)
{
var shimWidth = 0;
var shimHeight = 0;

// Open current popup
// Create the popup element
var dateEditorShim;
dateEditorShim = document.getElementById("dateEditorShim");
dateEditorShim.style.width = 0;
dateEditorShim.style.height = 0;
dateEditorShim.style.top = 0;
dateEditorShim.style.left = 0;
dateEditorShim.style.display = "none";
}


//add this in code
calDOB.OnClientShown = "dateEditor_OnShown";
calDOB.OnClientHiding = "dateEditor_OnHiding";