的RegisterClientScriptBlock参数在实际情况下的用法? [英] RegisterClientScriptBlock parameters usages in real scenarios?

查看:407
本文介绍了的RegisterClientScriptBlock参数在实际情况下的用法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://i.stack.imgur.com/dVjHt.jpg

我永远无法理解的实际使用的控制键入用法这个类的。

I never understood the real usage of the Control , type,key usages of this class.

在一般我总是使用:此,的GetType(),XX

但现在我真的想明白了。

but now I truly want to understand .

MSDN:

控制:这是注册客户端脚本控制

Control : " the control that is registering the client script"

所以...?什么区别它使谁注册了吗?该脚本会在页面的头部。的。

键入:客户端脚本块的类型

Type: "the type of the client script block"

型???它的JavaScript。为何要把其他类型的我?

:独特的indentifier

Key: "a unique indentifier"

那我可以理解 - 对案件后来删除......但我对于一些更高级的解释爱

我可以请一个真正的生活场景中,我的信利与这些PARAMS玩?

Can I have please , a real life scenario in which I TRULY have to play with those params ?

推荐答案

最重要的部分是控制 在HTML标签用来控制你要注册的脚本 例如,如果你有用户控件,你想运行只为使用该行的脚本

the most important part is Control which control in html tags you want to register the script for example if you have user control and you want to run the script just for that use this line

ScriptManager.RegisterStartupScript(this, this.GetType(), "alertscript", "document.getElementById('userControl_h1TAG')", true); 

但是当你想要注册的块和脚本的所有部分使用此行用户控制的CS code:

but when you want to register the block and script to all part of that page use this line in CS code of user-control :

ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "alertscript", "document.getElementById('page_h1TAG')", true);

这篇关于的RegisterClientScriptBlock参数在实际情况下的用法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆