MCTS, Share point,BA, UML, XML,Framework 1.1/2.0/3.5,Asp.net, Biz Talk Server, SPD, Windows server 2000/03/08
Monday, March 28, 2011
Pass Web part Custom property value to UserControls
// Create Custom Property in Webpart ---------------------------
[
Personalizable(),
Category("Miscellaneous"),
DefaultValue(""),
WebBrowsable(true),
WebDisplayName("Enter SK Form ID"),
WebDescription("Enter SK Form ID")
]
public string SKForm
{
get { return _skform; }
set { _skform = value; }
}
// End of Create Custom Property in Webpart ---------------------------
//-------------------------------------------------------------
protected override void CreateChildControls()
{
base.CreateChildControls();
userControl = (UserControl)Page.LoadControl(@"/_controltemplates/PraveshUserControl.ascx"); // Call UC
Type myControlType = userControl.GetType();
PropertyInfo MyControlProperty = myControlType.GetProperty("FormGUIDNos");
MyControlProperty.SetValue(userControl, SKForm, null); // Set value to UC Public Property
this.Controls.Add(userControl);
}
// End of -------------------- Create Child Controls
//-----------------------User Controls---------
public string _guidno;
public string FormGUIDNos
{
get { return _guidno; }
set { _guidno = value; }
}
// and Access this property anywhere in UC
[
Personalizable(),
Category("Miscellaneous"),
DefaultValue(""),
WebBrowsable(true),
WebDisplayName("Enter SK Form ID"),
WebDescription("Enter SK Form ID")
]
public string SKForm
{
get { return _skform; }
set { _skform = value; }
}
// End of Create Custom Property in Webpart ---------------------------
//-------------------------------------------------------------
protected override void CreateChildControls()
{
base.CreateChildControls();
userControl = (UserControl)Page.LoadControl(@"/_controltemplates/PraveshUserControl.ascx"); // Call UC
Type myControlType = userControl.GetType();
PropertyInfo MyControlProperty = myControlType.GetProperty("FormGUIDNos");
MyControlProperty.SetValue(userControl, SKForm, null); // Set value to UC Public Property
this.Controls.Add(userControl);
}
// End of -------------------- Create Child Controls
//-----------------------User Controls---------
public string _guidno;
public string FormGUIDNos
{
get { return _guidno; }
set { _guidno = value; }
}
// and Access this property anywhere in UC
Subscribe to:
Posts (Atom)