473,505 Members | 15,036 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Panel Controls inside a custom server control in ASP.NET

I want to create a simple server control that does thing like:

<Mc:CollapsibleControl TitlePanelID="panel1" BodyPanelID="Panel2">
<asp:Panel ID="panel1">
...
</asp:Panel>

<asp:Panel ID="panel2">
...
</asp:Pane2>
</Mc:CollaspableControl>

I based my custom web server control on the example you can find on:
http://msdn2.microsoft.com/en-us/library/ms178654.aspx

I defined a "Panels" property that return an array of "Panel" class.

What should I change to make it work? Thanks

Charles Zhang
Oct 6 '06 #1
3 1825
Hi Charles,

You need to apply ParseChildrenAttribute(false) on your custom control to
let the default ControlBuilder to interpret the content within your
control's begin and end tags. The parsed objects are added to your control
via the AddParsedSubObject method of your control. By default, the
AddParsedSubObject method expect server controls and adds these parsed
controls into your control's Controls collection as child controls.

Since you're only wanting Panel controls added to your controls collection,
you can do this by:

[ParseChildren(false)]
public class C1 : WebControl
{
private List<Panelm_panels = new List<Panel>();

protected override void AddParsedSubObject(object obj)
{
if (obj is Panel)
{
Panel p = (Panel)obj;
m_panels.Add(p);
Controls.Add(p);
}
}

public List<PanelPanels
{
get { return m_panels; }
}
}

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 6 '06 #2
I got the problem resolved. The code I wrote is working. However, the
web page does not use the new assembly until I restarted the web site.
To avoid the problem during debugging, I moved the custom user control
to "App_Code".


Charles Zhang wrote:
I want to create a simple server control that does thing like:

<Mc:CollapsibleControl TitlePanelID="panel1" BodyPanelID="Panel2">
<asp:Panel ID="panel1">
...
</asp:Panel>

<asp:Panel ID="panel2">
...
</asp:Pane2>
</Mc:CollaspableControl>

I based my custom web server control on the example you can find on:
http://msdn2.microsoft.com/en-us/library/ms178654.aspx

I defined a "Panels" property that return an array of "Panel" class.

What should I change to make it work? Thanks

Charles Zhang

Oct 6 '06 #3
Hi Charles,

Thanks for the update.

Is your web application migrated from ASP.NET 1.1? Or, are you using the
Web Application Project add-on for VS2005?

As for VS2005, it's recommened to put classes in the App_Code folder.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 9 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
10821
by: Fabrizio | last post by:
Hi, There is any chance to insert a control like a text box in a panel choosing the absolute position? When I try to insert a label , the panel positions the control on a locked position. Thanks...
3
3621
by: TT (Tom Tempelaere) | last post by:
Hi there, In my application I have a panel that contains a matrix of user controls. The user control is fairly simple. It merely draws a circle that represents an object in my code. The object...
1
2465
by: Tia Carr | last post by:
When I try to place a child control on top of a panel control, the mouse pointer remains as a pointer instead of changing to a cross. I tried both the ShowGrid on/off, doesn't make a difference.....
4
1776
by: Alexandre Soares | last post by:
Hi, If I make a control that derives from panel, how can I persist the state of the controls that are inside the panel when it is not rendered (visible = false)? The reason for this is that...
2
3602
by: Don Wash | last post by:
Hi There! I'm creating my website with ASP.NET + XHTML, which means I will strictly adhere the XHTML standards for my web page output. I use Panel or PlaceHolder WebControls to place...
2
1414
by: Raghu Raman | last post by:
Hi, am a biginner in .net designing.Does the panel control is enough to act as a container .Because if , i design my controls in textboxes rows& cols , i heared that the aclignment won't change...
15
2151
by: Arpan | last post by:
Consider the following code which retrieves data from a SQL Server 2005 DB table & displays it in a DataGrid: <script runat="server"> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)...
4
6861
by: tshad | last post by:
I am trying to hide and show certain parts of my code (which I have no problem doing with DW). In VS 2003, it won't let you use <div runat="server"to section of parts of my code in a table. This...
1
4816
by: mbruyns | last post by:
i have been trying (and sometimes succeeding) to use the modalpopupextender to show various panels of controls on my asp pages. the strange problem that i keep on running into is that sometimes it...
0
7367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5613
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5028
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4699
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1528
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
407
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.