当 ApplyChanges 返回 false 时,如何设置 EditorPart 的错误消息?
我正在使用 WebPartManager 开发自定义 ASP.Net WebPart,并且我也在创建自定义 EditorPart。对于其 EditorPart.ApplyChanges 方法,每当出现错误时,我都会将返回值设置为 false。
在 EditorZone 中,我收到一条标准错误消息,表明编辑器发生了一些错误,但我想更改该消息。 这可能吗?像...
public override bool ApplyChanges()
{
try
{
// save properties
return true;
}
catch(Exception ex)
{
ErrorMessage = ex.Message; // is there any similar property I can fill?
return false;
}
}
I'm developing a custom ASP.Net WebPart using the WebPartManager and I'm creating a custom EditorPart too. For its EditorPart.ApplyChanges method I set the return value to false whenever there is an error.
In the EditorZone I get a standard error message indicating that some error happened to the editor, but I want to change that message.
Is that possible? Something like...
public override bool ApplyChanges()
{
try
{
// save properties
return true;
}
catch(Exception ex)
{
ErrorMessage = ex.Message; // is there any similar property I can fill?
return false;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在 social msdn,但我不确定它是否正确,因为它没有很好的记录。您必须在 PreRender 方法中设置错误,如下所示:
I've found one solution in social msdn, but I'm not sure it is correct because it is not very well documented. You have to set the error in the PreRender method, something like this: