i have created a web-part that user will define the url to render and after user insert the web part on the page it did not renders, user have to edit and enter the url and click apply or ok button in the prop.
here is my code i am using...
string SiteUrl = SPContext.Current.Site.Url;//Get the url of current site
using (SPSite site = new SPSite(SiteUrl))
{
SPWeb web = site.OpenWeb();
SPFile webPartPage = web.GetFile(SPContext.Current.ListItemServerRelativeUrl);
SPLimitedWebPartManager webPartManager = webPartPage.GetLimitedWebPartManager(System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
web.AllowUnsafeUpdates = true;
pvwp.Title = WebPart.WebPartTitle;
pvwp.Description = WebPart.WebPartDescription;
if (string.IsNullOrEmpty(WebPart.WebPartContentLink.ToString()))
{
pvwp.ContentLink = "http://www.cnn.com";
}
pvwp.Width = "10in";
pvwp.Height = "15in";
pvwp.ContentLink = WebPart.WebPartContentLink.ToString();
//webPartManager.AddWebPart(pvwp, "TOP", 0);
this.Controls.Add(pvwp);
}