admin管理员组文章数量:1326478
I built a control with a RenderingTemplate for a custom ContentType. It contains additional buttons. If the code behind one button fails, I want to inform the user with a message box.
I tried
string script = "<script language='javascript'>MsgBox('" + errorMessage + "')</script>";
Page.ClientScript.RegisterClientScriptBlock(GetType(), "Register", script);
But it doesn't show and I can't find the javascript code in the rendered page. What am I doing wrong? Is there a special SharePoint message box class in SharePoint 2010?
I built a control with a RenderingTemplate for a custom ContentType. It contains additional buttons. If the code behind one button fails, I want to inform the user with a message box.
I tried
string script = "<script language='javascript'>MsgBox('" + errorMessage + "')</script>";
Page.ClientScript.RegisterClientScriptBlock(GetType(), "Register", script);
But it doesn't show and I can't find the javascript code in the rendered page. What am I doing wrong? Is there a special SharePoint message box class in SharePoint 2010?
Share Improve this question asked Nov 1, 2010 at 15:53 HinekHinek 9,73912 gold badges54 silver badges75 bronze badges 3- 2 Is this the jQuery MsgBox or something else? Have you tried the standard javascript alert()? Do you get any error on the page, or is the code just not executed at all? – Peter Jacoby Commented Nov 2, 2010 at 2:52
- alert() works, thanks. But I'm looking for something similar to the SharePoint standard message boxes (like when you're trying to delete a list) – Hinek Commented Nov 2, 2010 at 7:59
- wait, I just saw, SharePoint actually uses alert() and confirm() for this ... ok, never mind ... @Peter Jacoby, if you post my snipped and replace MsgBox with alert, I will accept the answer. – Hinek Commented Nov 2, 2010 at 8:02
1 Answer
Reset to default 2From the ments it sounds like a simple change from MsgBox to alert will work for you. So you would just need the code to slightly modified to:
string script = "<script language='javascript'>alert('" + errorMessage + "')</script>";
Page.ClientScript.RegisterClientScriptBlock(GetType(), "Register", script);
本文标签: cHow to popup a message box in SharePoint 2010Stack Overflow
版权声明:本文标题:c# - How to popup a message box in SharePoint 2010 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742207538a2433098.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论