在客户端脚本中写以下红色的代码是何道理?我们一般只会在 HTML 文件中写。
<script type="text/javascript">
function getAgeByName()
{
var context = "";
var name = document.getElementById('txtName').value;
<%= Page.ClientScript.GetCallbackEventReference(this, "name", "ReceiveDataFromServer", "context") %>; }
function ReceiveDataFromServer(retVal)
{
document.getElementById('result').innerText = retVal;
}
</script>
<script type="text/javascript">
function getAgeByName()
{
var context = "";
var name = document.getElementById('txtName').value;
<%= Page.ClientScript.GetCallbackEventReference(this, "name", "ReceiveDataFromServer", "context") %>; }
function ReceiveDataFromServer(retVal)
{
document.getElementById('result').innerText = retVal;
}
</script>
解决方案 »
- 高手指教!计时器刷新依然计时问题!!!
- 如何将复选框中心部分的背景改为其他颜色??
- 让键盘操作不起作用
- 写SQL语句时最用参数传递
- ConfigurationSettings.AppSettings.Add怎么用?
- 用下面代码进行页面的用户验证,会不会被绕过验证,直接进入页面呢?
- 动态添加图片元素
- asp.net(C#)+oracle9i要顶住二三千人在线频率很高的提交
- 关于Integrate Windows Authentication SSO的问题
- Help!!!!如何在现有的DataView表中进行SQL条件判断?并在此基础上再生成另一个DataView?
- where中有中文就查不到结果
- 怎么取消Freetextbox的自动修改text内容
为什么要这么写:个人习惯,比较简单。为什么不这么写:一般建议用external javascript (SEO等方面原因),这个只在同一页面中有效。
能生成什么HTML:自己看一下HTML源代码。
怎么生成想要的HTML:用Reflector看一下ASP.NET临时文件夹下编译好的dll就知道了。
Control control,
string argument,
string clientCallback,
string context
)参数
control
类型:System.Web.UI..::.Control处理客户端回调的服务器 Control。该控件必须实现 ICallbackEventHandler 接口并提供 RaiseCallbackEvent 方法。
使用 GetCallbackEventReference就直接输出了触发客户端回调的代码,就像GetPostEventReference 方法直接输出出发客户端回发的代码一样,无需写一行javascript。