We need to override the Verbs property of Web Part, change the following code:
public override WebPartVerbCollection Verbs
{
get
{
return base.Verbs;
}
}
Change the code to be like
public override WebPartVerbCollection Verbs
{
get
{
List< WebPartVerb> newVerbs=new List< WebPartVerb>();
WebPartVerb verb1=new WebPartVerb(this.ID+"verb1", new WebPartEventHandler(ServerSideHandler));
verb1.Text="....";
verb1.Visible=true;
verb1.Description="....verb1";
newVerbs.Add(verb1);
WebPartVerb verb2=new WebPartVerb(this.ID+"verb2","alert('verb2');");
verb.Text="...";
...
newVerbs.Add(verb2);
WebPartVerbCollection myVerbs=new WebPartVerbCollection(base.Verbs, newVerbs);
return myVerbs;
}
}
public void ServerSideVerbHandler(object sender, WebPartEventArgs e){...}
No comments:
Post a Comment