Pages

Thursday, December 27, 2007

Drag-n-Drop with Resizable object across iframe

I got a weird problem when dealing with Resizable Drag-n-Drop (RDD) object across iframe. I have a RDD object which is required to be movable and resizable on an iframe enclosed by a div tag. When the object is out side of the iframe, everything works really well (with both scriptaculous + prototype and jQuery libraries). However, the object seems to over-sticky and out of control by mouse events on iframe. It took me nearly three days to figure out that the problem came on the render of object over iframe.

To fix this problem, I try to make a "layer" with transparent background (I highly recommend that you should make a transparent 1x1 pixels image, this will help you out of most of the problem with browsers) which lays upon the iframe, this will create a virtual background to keep RDD working promptly on iframe.

Monday, December 17, 2007

Gửi email tự động qua Yahoo

Yêu cầu: Yahoo Mail

* Chủ nhân của 1 web hosting trên Yahoo với Username/Password đầy đủ.
* Email account phải được thiết lập sẵn trên Yahoo server.
* Có nhu cầu gửi email reply bằng code, chứ không phải gửi Spam mail

Giải quyết:

* POP3: pop.bizmail.yahoo.com, port 110
* SMTP: smtp.bizmail.yahoo.com, port 587, chứ không phải port 25 nhưng thông thường
* Username: [tên account]@[tên miền (domain)].com
* Password: [ẩn]

Hàm trả về nhiều giá trị thuộc nhiều dạng dữ liệu

Yêu cầu:
  • Sử dụng ngôn ngữ C#
  • Muốn viết 1 hàm trả về nhiều hơn 1 giá trị với các kiểu biến (data type) khác nhau.

Giải quyết:
  • Tạo 1 hàm với biến trả về array các object.
  • Gán các biến đầu vào lên array đó.
  • Trả về array các object.

private object[] GetObjectWithMultipleDataType([những giá trị đầu vào của hàm])
{
object _myObject = new object[3];
// Khai báo và khởi tạo giá trị trả về
_myObject[0] = “My name is FHDN”;
// Gán giá trị đầu của array thành kiểu string
_myObject[1] = 100;
// Gán giá trị thứ 2 thành kiểu int
SortedList _myList = new SortedList();
// Khai báo và khởi tạo biến phức kiểu SortedList
_myObject[2] = _myList;
return _myObject;
}

Sử dụng:

object[] expectedObject = GetObjectWithMultipleDataType([những giá trị đầu vào của hàm]);
string expectedString = (string)expectedObject[0];
int expectedInt = (int)expectedObject[1];
SortedList expectedList = new SortedList();
expectedList = (SortedList)expectedObject[2];