Registerstartupscript不适用于scriptmanager,updatepanel。这是为什么? [英] Registerstartupscript doesnt work with scriptmanager, updatepanel. Why is that?

查看:60
本文介绍了Registerstartupscript不适用于scriptmanager,updatepanel。这是为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< asp:updatepanel id =UpdatePanel3runat =serverupdatemode =Conditionalxmlns:asp =#unknown>

< asp:gridview id =grdViewAllStudyrunat =serverautogeneratecolumns =False>

OnRowDataBound =grdViewAllStudy_RowDataBound>

< asp:templatefield headertext =Action>

< asp:linkbutton id =btnAuditTrailoncommand =btnAuditTrail_commandcommandargument =<%#Eval(StudyCodeId)%>>

Text ='查看历史'runat =server>



我尝试过: < br $>


string strEncrypt = clsCommon.Encrypt_QueryString(Convert.ToString(110));

string pageurl =frmViewUpdateHistoryPage.aspx?StudyCodeID = + strEncrypt +;

StringBuilder sb = new StringBuilder();

sb.Append(< script type ='text / javascript'>) ;

sb.Append(window.open(');

sb.Append(pageurl);

sb.Append( '););

sb.Append(< / script>);



1] ClientScript.RegisterStartupScript(this .GetType(),script,sb.ToString());

2] ScriptManager.RegisterStartupScript(this.GetType(),Window,script,sb.ToString(),真的);



我使用了2以上选项,但仍然无法正常工作,请帮助.........

注意::在我的源代码中,我关闭了GridView以及UpdateP anel。

<asp:updatepanel id="UpdatePanel3" runat="server" updatemode="Conditional" xmlns:asp="#unknown">
<asp:gridview id="grdViewAllStudy" runat="server" autogeneratecolumns="False">
OnRowDataBound="grdViewAllStudy_RowDataBound">
<asp:templatefield headertext="Action">
<asp:linkbutton id="btnAuditTrail" oncommand="btnAuditTrail_command" commandargument="<%#Eval("StudyCodeId")%>">
Text='View History' runat="server">

What I have tried:

string strEncrypt = clsCommon.Encrypt_QueryString(Convert.ToString("110"));
string pageurl = "frmViewUpdateHistoryPage.aspx?StudyCodeID=" + strEncrypt + "";
StringBuilder sb = new StringBuilder();
sb.Append("<script type = 'text/javascript'>");
sb.Append("window.open('");
sb.Append(pageurl);
sb.Append("');");
sb.Append("</script>");

1] ClientScript.RegisterStartupScript(this.GetType(), "script",sb.ToString());
2] ScriptManager.RegisterStartupScript(this.GetType(),"Window", "script", sb.ToString(),true);

I used above 2 option, But Still it is not working ,Please Help.........
Note :: In my Source Code I close GridView as well as UpdatePanel.

推荐答案

试试这个

try this
string script = sb.ToString();
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", script, false);


这篇关于Registerstartupscript不适用于scriptmanager,updatepanel。这是为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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