1

对于这个看起来很初级的问题,我深表歉意,但在 C# 中还有很多东西要学!

在某些条件下,我试图在页面加载时弹出一条消息。

我的 If/Else If 已全部设置并且工作正常,现在我需要在满足某些条件时添加弹出消息。

我的问题是,我只使用过这样的东西:

ScriptManager.RegisterStartupScript(btnSubmitWork, typeof(Button), "Data Entry", 
"alert('Please note that you are in the UAT link')", true);

但是,这次将不涉及任何按钮,我希望它在页面加载时弹出。

如何实现?

4

2 回答 2

2

而不是使用按钮使用PageGetType()作为前两个参数:

ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Data Entry", 
"alert('Please note that you are in the UAT link');", true);
于 2015-08-26T13:21:03.767 回答
0

结合 hutchonoid 的答案和链接上发布的接受的答案,我能够使用它来工作:

ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Data Entry", 
"alert('Please note that you are in the UAT link');", true);

只有 2 个微小的差异;使用“Page.GetType()”而不是“GetType()”,并在警报消息末尾使用分号。我会给 hutchonoid 支票,因为他把我带到了那里。

于 2015-08-26T13:40:49.300 回答