Custom panel control
-
I want to creat own custom panel control to add some features into default Panel & I donot want to inhert mypanel class from Panel i am trying to use System.Web.UI.Design.ReadWriteControlDesigner to get design time festures, drag & drop control on mypanel but can't get any success I am new in Custom Controls Can you give me any pieace of code so that i can take some guidline Actualy i want to build colapsable panel Thanks Arfan
-
I want to creat own custom panel control to add some features into default Panel & I donot want to inhert mypanel class from Panel i am trying to use System.Web.UI.Design.ReadWriteControlDesigner to get design time festures, drag & drop control on mypanel but can't get any success I am new in Custom Controls Can you give me any pieace of code so that i can take some guidline Actualy i want to build colapsable panel Thanks Arfan
Hi there, Becaus you didn't post your sample code so could not understand why your custom control doesn't work. Below is a very very simple custom panel using a custom designer which inherits from the ReadWriteControlDesigner:
[Designer(typeof(MyPanelDesigner)),
PersistChildren(true),
ParseChildren(false),
ToolboxData("<{0}:MyPanel runat=server>MyPanel</{0}:MyPanel>")]
public class MyPanel : WebControl
{
public MyPanel(): base()
{
}
}public class MyPanelDesigner : ReadWriteControlDesigner
{
public MyPanelDesigner(){}
}For more information, you can see Design-Time Support for Web Forms[^] shahzadarfan wrote: Actualy i want to build colapsable panel I guess you might also want to check out the ASP.NET control gallery[^].
-
Hi there, Becaus you didn't post your sample code so could not understand why your custom control doesn't work. Below is a very very simple custom panel using a custom designer which inherits from the ReadWriteControlDesigner:
[Designer(typeof(MyPanelDesigner)),
PersistChildren(true),
ParseChildren(false),
ToolboxData("<{0}:MyPanel runat=server>MyPanel</{0}:MyPanel>")]
public class MyPanel : WebControl
{
public MyPanel(): base()
{
}
}public class MyPanelDesigner : ReadWriteControlDesigner
{
public MyPanelDesigner(){}
}For more information, you can see Design-Time Support for Web Forms[^] shahzadarfan wrote: Actualy i want to build colapsable panel I guess you might also want to check out the ASP.NET control gallery[^].
Thanks for your reply its working now i was missing class atribute tag Now one other question how to render server side control from custom control with this MyPanel class I want to store some value in hidden box so that it can be availble on post back. but simple html control lose it value on post back Thanks
-
Thanks for your reply its working now i was missing class atribute tag Now one other question how to render server side control from custom control with this MyPanel class I want to store some value in hidden box so that it can be availble on post back. but simple html control lose it value on post back Thanks
shahzadarfan wrote: Now one other question how to render server side control from custom control with this MyPanel class There are two common ways to render the child controls of a custom control: + Override the Render method. + Override the CreateChildControls method. shahzadarfan wrote: I want to store some value in hidden box so that it can be availble on post back. but simple html control lose it value on post back Make sure that your child controls are created before the ViewState data is loaded in the control life cycle when a postback occurs