del método ToolPart.ApplyChanges
Se llama cuando el usuario hace clic en el OK o en el botón Apply en el panel de herramientas.
Espacio de nombres: Microsoft.SharePoint.WebPartPages
Ensamblado: Microsoft.SharePoint (en Microsoft.SharePoint.dll)
Sintaxis
'Declaración
Public Overridable Sub ApplyChanges
'Uso
Dim instance As ToolPart
instance.ApplyChanges()
public virtual void ApplyChanges()
Ejemplos
En el siguiente ejemplo se muestra el uso del método ApplyChanges para aplicar el nuevo valor (especificado por el usuario en un cuadro de texto en el panel de herramientas) para el elemento Web previsto.
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