ASP.Net-在用户控制服务器端方法中调用javascript
|
我有一个带有公共方法的用户控件:
public void ShowDetails(Guid requestGuid)
{
Label1.Text = reportGuid.ToString(); //only for testing
ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), \"ShowEmailPreview\", \"alert(\'hi\');\", true);
//ScriptManager.RegisterStartupScript(this, this.GetType(), \"ShowEmailPreview\", \"alert(\'hi\');\", true); //doesn\'t work
//Page.ClientScript.RegisterStartupScript(this.GetType(), \"ShowEmailPreview\", \"alert(\'hi\');\", true); //doesn\'t work
}
当此用户控件的托管页面调用ShowDetails()时,我需要调用一些javascript。
我尝试使用ScriptManager.RegisterStartupScript和Page.ClientScript.RegisterStartupScript,但是它不起作用...但是,如果我在控件上添加UpdatePanel并为如上所述的UpdatePanel添加脚本,则效果很好。
我不想只是为了调用javascript而将UpdatePanel添加到我的控件中。
我想念什么吗?
谢谢!
没有找到相关结果
已邀请:
2 个回复
癸痊醒
诉嘎归亮
这是一个较短的版本