I'm passing parameters to a WebPart from a textbox to have a better UI experience for a personalizable WebPart which in this case takes the form of a twitter feed.
The problem I have, is in the scenario that a user has more than one instance of this WebPart on the page, the click event which sets the parameter cannot tell which WebPart is making the call.
Can I pass some kind of parameter from EventArgs to GetLimitedWebPartManager that identifies a unique instance of the WebPart?
protected void setTwitterName_Click(object sender, EventArgs e)
{
string Name = TwitterHandle.Text.Trim();
if (!String.IsNullOrEmpty(Name))
{
using (var webPartManager = SPContext.Current.Web.GetLimitedWebPartManager("default.aspx",PersonalizationScope.User))
{
try
{
foreach (var twitterWebPart in webPartManager.WebParts.Cast<WebPart>().Where(webPart => webPart.Title == "Twitter").Cast<Twitter>())
{
twitterWebPart.Name = Name;
webPartManager.SaveChanges(twitterWebPart);
PropertiesWebPart.Name = Name;
DisplayTweets();
}
}
catch
{
}
}
}
}
sender
parameter, that usually is the object that triggered the call.