ScriptManager的立即运行脚本 [英] ScriptManager run script immediately
本文介绍了ScriptManager的立即运行脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个更新面板加载用户的控制,这里的目标是有所谓的这个时候发生了特定的JavaScript函数。我在想这会通过脚本管理器来完成,虽然这并不需要是如果有一个HTML替代的情况。
流动基本上是以下内容:
- 用户点击按钮
- 更新面板负载控制
- JavaScript函数叫做
非常感谢
我已经尝试过的RegisterStartupScript(..)
,虽然我可能已经做出了错误的语法
如果(显示)
{
字符串scriptId =的String.Format({0}:脚本,++ uniquePopupId);
字符串scriptTag =的String.Format(showPopup({0},{1});,宽度,高度);
ScriptManager.RegisterStartupScript(这一点,this.GetType(),scriptId,scriptTag,真正的);
}
解决方案:
如果(显示)
{
字符串scriptId =的String.Format({0}:脚本,++ uniquePopupId);
字符串scriptTag =的String.Format(showPopup({0},{1});,宽度,高度);
ScriptManager.RegisterStartupScript(updPanelChildControl,updPanelChildControl.GetType(),scriptId,scriptTag,真正的);
}
解决方案
使用
ScriptManager.RegisterStartupScript(myControlInstance,
typeof运算(MyControl)
键,
我的JavaScript字符串这里
真正);
这里。
I have an update panel load a user control, and the goal here is to have a specific JavaScript function called when this occurred. I was thinking this would be done through the Script Manager, though this does not need to be the case if there's an html alternative.
The flow is basically the following:
- User clicks button
- Update panel loads control
- Javascript function is called
Many thanks
I've already tried RegisterStartupScript(..)
, though i may have made a syntactical mistake
if (show)
{
string scriptId = String.Format("{0}:script", ++uniquePopupId);
string scriptTag = String.Format("showPopup({0},{1});", Width, Height);
ScriptManager.RegisterStartupScript(this, this.GetType(), scriptId, scriptTag, true);
}
Solution:
if (show)
{
string scriptId = String.Format("{0}:script", ++uniquePopupId);
string scriptTag = String.Format("showPopup({0},{1});", Width, Height);
ScriptManager.RegisterStartupScript(updPanelChildControl, updPanelChildControl.GetType(), scriptId, scriptTag, true);
}
解决方案
Use
ScriptManager.RegisterStartupScript(myControlInstance,
typeof(MyControl),
"key",
"my javascript string here",
true);
Documentation here.
这篇关于ScriptManager的立即运行脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文