Trying to report error to Sharepoint ToolPane

1
2
3
4
5
6
/// <summary>
/// A custom editor part for picking data fields for a table web part
/// </summary>
class CustomEditorPart:EditorPart
{
#region Declarations
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// In addition to other controls, etc, declare an error variable

string _errorText = string.Empty;

#endregion Declarations

#region Apply Changes

/// <summary>
/// Applies the changes to the web part properties
/// </summary>
/// <returns></returns>
public override bool ApplyChanges()
{
try
{

// You code goes here

return true;
}
catch (Exception ex)
{
_errorText = ex.Message;
return false;
}
}

#endregion Apply Changes

#region Rendering (Error Text)

/// <summary>
/// Update the error text if needed
/// </summary>
/// <param name="e"></param>
protected override void OnPreRender(EventArgs e)
{
if (_errorText != string.Empty)
{
this.Zone.ErrorText += Environment.NewLine + _errorText;
}

base.OnPreRender(e);
}
1
2
#endregion Rendering (Error Text)
}

来源: http://goo.gl/IbOo

发表评论

电子邮件地址不会被公开。

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>