<?php
class Page_T
{
private $isPostBack;
public $ViewState;
function __construct()
{
$this->isPostBack = false;
if (isset($_POST['__EVENTTARGET']) && $_POST['__EVENTTARGET'] != "")
{
$this->isPostBack = true;
}
$this->ViewState = $_POST;
unset($this->ViewState['__VIEWSTATE']);
unset($this->ViewState['__EVENTTARGET']);
unset($this->ViewState['__EVENTARGUMENT']);
}
function isPostBack()
{
return $this->isPostBack;
}
function Run()
{
if ($this->isPostBack())
{
$this->$_POST['__EVENTTARGET']($_POST['__EVENTARGUMENT']);
}
}
}
class WebForm1_T extends Page_T
{
function __construct()
{
parent::__construct();
}
function Page_Load()
{
if (!$this->isPostBack())
{
$this->ViewState['TextArea1'] = "现在的时间是: " . date("Y-m-d H:i:s");
}
}
function Button2Click($EventArgument)
{
$this->ViewState['TextBox1'] = date("Y-m-d H:i:s");
}
}
$WebForm1 = new WebForm1_T();
$WebForm1->Page_Load();
$WebForm1->Run();
?>
<HTML>
<HEAD>
<title>WebForm1</title>
</HEAD>
<body>
<form name="Form1" method="post" action="test.php" id="Form1">
<input type="hidden" name="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" value="" />
<script language="javascript">
<!--
function __doPostBack(eventTarget, eventArgument) {
var theform;
if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
theform = document.forms["Form1"];
}
else {
theform = document.Form1;
}
theform.__EVENTTARGET.value = eventTarget;
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
// -->
</script>
<textarea name="TextArea1" id="TextArea1" cols="60"><?=$WebForm1->ViewState['TextArea1']?></textarea><br/>
<input type="text" name="TextBox1" id="TextBox1" value="<?=$WebForm1->ViewState['TextBox1']?>"/>
<br>
<input language="javascript" onclick="__doPostBack('Button2Click','')" name="Button2" id="Button2" type="button" value="提交" />
</form>
</body>
</HTML>