ToolPart.ApplyChanges method
Chamado quando o usuário clica o OK ou o botão Apply no painel de ferramentas.
Namespace: Microsoft.SharePoint.WebPartPages
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'Declaração
Public Overridable Sub ApplyChanges
'Uso
Dim instance As ToolPart
instance.ApplyChanges()
public virtual void ApplyChanges()
Examples
O exemplo a seguir demonstra o uso do método ApplyChanges para aplicar o novo valor (inserido pelo usuário em uma caixa de texto no painel de ferramentas) para a Web Part desejada.
public class SimpleToolPart : ToolPart
{
TextBox tb;
bool changed=false;
WebPart WebPartReference;
protected override void CreateChildControls()
{
WebPartReference = (WebPart)ParentToolPane.SelectedWebPart;
tb=new TextBox();
tb.Text = WebPartReference.Title;
tb.TextChanged+=new EventHandler(tbChanged);
Controls.Add(tb);
}
protected override void RenderToolPart(HtmlTextWriter w)
{
this.RenderChildren(w);
}
private void tbChanged(object sender, System.EventArgs e)
{
changed=true;
}
public override void ApplyChanges()
{
if(changed)
WebPartReference.Title=tb.Text;
}
public override void SyncChanges()
{
tb.Text=WebPartReference.Title;
}
}
Public Class SimpleToolPart
Inherits ToolPart
Private tb As TextBox
Private changed As Boolean=False
Private WebPartReference As WebPart
Protected Overrides Sub CreateChildControls()
WebPartReference = CType(ParentToolPane.SelectedWebPart, WebPart)
tb = New TextBox()
tb.Text = WebPartReference.Title
AddHandler tb.TextChanged, AddressOf tbChanged
Controls.Add(tb)
End Sub
Protected Overrides Sub RenderToolPart(ByVal w As HtmlTextWriter)
Me.RenderChildren(w)
End Sub
Private Sub tbChanged(ByVal sender As Object, ByVal e As System.EventArgs)
changed=True
End Sub
Public Overrides Sub ApplyChanges()
If changed Then
WebPartReference.Title=tb.Text
End If
End Sub
Public Overrides Sub SyncChanges()
tb.Text=WebPartReference.Title
End Sub
End Class