Wednesday, November 12, 2008

prado - attaching event handler to dynamically added control

Prado attaching event handler for a control added dynamically-

When we create a control in prado dynamically through code, we need to attach a event handler to it.
For this, control has a method 'attachEventHandler' which we can use.

For example, we create a following control

public function onPreLoad()
{
//create a control
$control = new TButton();
//attach event handler
$control.attachEventHanler('OnClick',array($this,'ButtonClicked');
//add above control
}
//event handler
public function ButtonClicked($sender,$param)
{
}//ButtonClicked

Note-
Attaching an eventHandler has to be done in method onPreLoad() otherwise if written on OnLoad method of page, eventHandler will not get called after event is invoked.



Ashwini

Thursday, November 6, 2008

send email with php

php has very simple code to send email.
For this it has provided a file 'Mail.php' which we add and are ready to send email.

Below is the sample code-

require_once 'Mail.php';

//set to field
$to = "to@domain.com";
//set subject filed
$subject = "email verification";
//set from filed
$from = "from@domain.com";
//set content
$content = "Click below link to confirm registration. http://localhost/PROJECT/index.php"
//get host
$host = "mail.host.com";
$username = "username";
$password = "password";

$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);

$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
//send email
$mail = $smtp->send($to, $headers, $content);


And thus we are done with sending email with php.