step1: this is the custom webpart manager i created.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
namespace CustomWebPartManager
{
[DefaultProperty("Text")]
[ToolboxData("<{0}:CustomWebPartManagerControl runat=server></{0}:CustomWebPartManagerControl>")]
public class CustomWebPartManagerControl : WebPartManager
{
[Bindable(true)]
[Category("Appearance")]
[DefaultValue("")]
[Localizable(true)]
public string Text
{
get
{
String s = (String)ViewState["Text"];
return ((s == null) ? String.Empty : s);
}
set
{
ViewState["Text"] = value;
}
}
public void SetDirty()
{
// Invoke the protected SetPersonalizationDirty method
SetPersonalizationDirty();
}
}
}
step2: Build this custom control Application, it will build successfully.
step3: Now go to your original application. there go to your toolbox, add a tab and right click there, choose the options, choose items. now a dialog box will come, through browse button, choose the dll file, that built in the custom control, now click ok.
then a control will add to your toolbox.
step4: Now drag that control into your webpage, in the place of webpartmanager. (when you drag, automatically the reister tag will come)
step5: Now Call the setDirty() method immediately after you adding your webpart.
Give a man a fish and you feed him for a day. Teach a man to fish and you feed him forever.