updatepanel注册js
来源:互联网 发布:xstream java 编辑:程序博客网 时间:2024/06/05 17:37
1、关于updatepanel注册js 最近在项目里需要用到altas,本人也是新手,老用最简单的updatepanel,在注册脚本时也遇到了困难,无法注册
。本来是在updatepanel中放了一个gridview,偶想在girdview中一个模板列点击弹出一个窗体,注册window.open()来解决问题。本来不是在
updatepanel中,所以用ClientScript.RegisterStartupScript直接注册挺好使。 在拖入updatepanel后发现无法注册脚本,想想
RegisterStartupScript本来是在页面加载时启动js的,在updatepanel中部分刷新,肯定是无法注册的。
后来发现了ScriptManager.RegisterStartupScript方法,挺好使,呵呵。 ScriptManager.RegisterClientScriptBlock(UpdatePanelName,
typeof(UpdatePanel), "标识key", "脚本", true); 下面是一个demo,
模板列定义如下:
<asp:TemplateField HeaderText="客户ID">
<ItemTemplate>
<asp:LinkButton ID="linkbtnCID" runat="server" Text='<%# Eval("CID") %>' CommandName="linkbtnCID" > </asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
在GridView对应的RowCommand事件中如下操作:
protected void gvClientInfo_RowCommand(object sender, GridViewCommandEventArgs e)
{
//如果是linkButton被点击
if(e.CommandName.Equals("linkbtnCID"))
{
LinkButton lbtn = (LinkButton)e.CommandSource;
GridViewRow dgRow = (GridViewRow)lbtn.Parent.Parent;
string tmpText = lbtn.Text.ToString();
tmpText ="window.open('customerDetailsInfo.aspx?CID=" + tmpText + "' ,'newwindow','height=550, width=700, menubar=no ')";
ScriptManager.RegisterStartupScript(this.UpdatePanel2, this.GetType(), "click", tmpText, true); } }
2、关于RegisterStartupScript,RegisterClientScriptBlock RegisterStartupScript 将 js嵌入到页面的底部,</form> 的前面
RegisterClientScriptBlock 将 js嵌入到页面中开启元素 <form> 后面
protected void btnRecving_Click(object sender, EventArgs e)
{
string content = CheckRecvingSelected();
if(content != string.Empty)
{
//其中注册的script的,不要带标记对,true表示自动加script标记对
ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "click", "alert('" + content + "');",
true);
return;
}
}
ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "click", "alert('请输入关键词!')", true);
ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "click", "window.open('index.aspx');", true);
运用的方法就是给UpdatePanel注册JS脚本!
- updatepanel注册js
- updatepanel里的js
- Updatepanel中使用异步控件的注册
- UpdatePanel与JS alert冲突
- UpdatePanel 中js失效问题
- UpdatePanel 中js失效问题
- UpdatePanel 更新后JS调用UpdatePanel外控件
- UpdatePanel
- updatepanel
- updatepanel
- UpdatePanel
- UpdatePanel
- updatepanel
- 在Updatepanel中使用JS的问题.
- 解决UPDATEPANEL只绑定一次JS事件
- UpdatePanel 中始终执行一个 JS 代码。
- 在asp.net UpdatePanel 执行脚本JS
- updatepanel 中使用JS alert方法
- 探讨智能家居行业市场低迷三原因
- Liferay:MVCPortlet文件下载的方法
- 没有重复字符的最长子串
- js引擎
- nor flash 与 nand flash 区别
- updatepanel注册js
- ISTQB AL知识点等级与考题分布-对考试有帮助
- 秋雨寄相思
- 学习设计模式比较好的网址
- 释义sql,conn,2,3数据库操作语言
- WinUSB Driver Installation
- ISAPI_Rewrite 2.9与3.0 对网站目录进行301重定向的正则表达式规则
- REDHAT 共享服务器配置(NFS+SAMBA)
- zf实例化Zend_Db_Adapter对象