This is a project that several people from my team are working on. What I am wanting to do is allow them to create a page then drag the custom control on to their page and drag controls inside the custom control. I am not sure if this is even possible. If
it is not I will probably just step back and keep reproducing the code on each page needed rather than use the user control.
Sorry about, didn't get a chance to get on the computer last night after work.
I see what your issue is, you are correct, you cannot 'drag and drop' additional controls onto a control in the Visual Studio Designer. My next question is, do you know what controls the other developers would be adding? In my opinion it would seem a little
overhead to manually add the controls to your control everytime there is a page load.
If you know what the other developers need you could always create additional user controls that they could then drag and drop onto the page as needed. The controls will be able to communicate with one another. Also, you start developing your own framework
on top of .NET.
Hope this helps a little more.
- Jesse
Jesse Williams
Please mark 'Answered' if my post was able to assist you.
I don't think my original post was very clear. I have gone in a slightly different direction. Same basic idea, but using Templates inside a user control.
I finally gave up and am just going to have the "title bar" be a user control. So I am not using the templates at all. I think this will get me what i need. Thank you Jesse for taking the time to help me.
Marked as answer by achuzan on Feb 15, 2008 05:57 PM
achuzan
0 Points
7 Posts
Adding Controls to a custom user control
Feb 14, 2008 08:08 PM|LINK
I am trying to make a "template" control that can be used as a fake window.
So it have a title bar, title icon and close button.
I have the control created, but when i add it to the aspx page I can not drag a button into the control.
Control code
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="webWindow.ascx.cs" Inherits="webWindow" %>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
<asp:Panel ID="webWindowPan" runat="server" cssClass="modalPopup" Width="500px" >
<table class="titleBar" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<asp:Image ID="webWindowTitleIcon" runat="server" Height="16px" ImageUrl="~/images/application.png" Width="16px" />
<asp:Label ID="webWindowTitle" runat="server" Font-Bold="True" Text="New Web Window" ForeColor="White" BackColor="Transparent" Height="20px"></asp:Label>
</td>
<td width="20" >
</td>
<td align="right" style="width: 55px">
<asp:ImageButton ID="webWindowCloseButton" runat="server" Height="16px" ImageUrl="~/images/close_gray.png" Width="40px" />
</td>
</tr>
</table>
<asp:Panel ID="webWindowContent" runat="server" Width="100%" >
Hello
</asp:Panel>
</asp:Panel>
ASPX Code -
<%@ Register src="webWindow.ascx" TagName="webWindow" TagPrefix="uc1" %>
<form id="form1" runat="server">
<ajaxToolkit:ToolkitScriptManager ID="ScriptManager1" runat="server" />
<div>
<uc1:webWindow id="WebWindow1" runat="server" >
</uc1:webWindow></div>
</form>
I have been searching and can't figure out how to edit the usercontrol in the aspx page to add content to the "window"
Thank you
psuphish05
Participant
1381 Points
278 Posts
Re: Adding Controls to a custom user control
Feb 14, 2008 08:27 PM|LINK
Try this in the Page_Load method of your .aspx page:
Hope this provides some insight.
- Jesse
Please mark 'Answered' if my post was able to assist you.
achuzan
0 Points
7 Posts
Re: Adding Controls to a custom user control
Feb 14, 2008 08:35 PM|LINK
Thank you Jesse,
This is a project that several people from my team are working on. What I am wanting to do is allow them to create a page then drag the custom control on to their page and drag controls inside the custom control. I am not sure if this is even possible. If it is not I will probably just step back and keep reproducing the code on each page needed rather than use the user control.
achuzan
0 Points
7 Posts
Re: Adding Controls to a custom user control
Feb 15, 2008 12:20 PM|LINK
Anyone else have any ideas?
psuphish05
Participant
1381 Points
278 Posts
Re: Adding Controls to a custom user control
Feb 15, 2008 01:25 PM|LINK
Sorry about, didn't get a chance to get on the computer last night after work.
I see what your issue is, you are correct, you cannot 'drag and drop' additional controls onto a control in the Visual Studio Designer. My next question is, do you know what controls the other developers would be adding? In my opinion it would seem a little overhead to manually add the controls to your control everytime there is a page load.
If you know what the other developers need you could always create additional user controls that they could then drag and drop onto the page as needed. The controls will be able to communicate with one another. Also, you start developing your own framework on top of .NET.
Hope this helps a little more.
- Jesse
Please mark 'Answered' if my post was able to assist you.
achuzan
0 Points
7 Posts
Re: Adding Controls to a custom user control
Feb 15, 2008 02:44 PM|LINK
Sorry Jesse,
I don't think my original post was very clear. I have gone in a slightly different direction. Same basic idea, but using Templates inside a user control.
I am looking for something like this
http://wss3.theseders.com/robsederblog/Lists/Posts/Post.aspx?List=4c9e886c%2D4b5c%2D4a3e%2D95a0%2De30b3f4a1e9c&ID=67
But I am getting an error on this that says "Type 'System.Web.UserControl' does not have a public property named 'ContentTemplate'
However I do have :)
[In the User Control]
private ITemplate _windowContent;
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if (_windowContent != null)
{
_windowContent.InstantiateIn(webWindowContent);
}
}
[PersistenceMode(PersistenceMode.InnerProperty),
TemplateContainer(typeof(TemplateControl))]
public ITemplate ContentTemplate
{
get { return _windowContent; }
set { _windowContent = value; }
}
achuzan
0 Points
7 Posts
Re: Adding Controls to a custom user control
Feb 15, 2008 03:27 PM|LINK
Found this also,
http://msdn2.microsoft.com/en-us/library/36574bf6(VS.80).aspx
My issue is getting it to somehow show up in the designer.
I tried the things in teh comments from the above page, but it doesn't change the results I am getting.
psuphish05
Participant
1381 Points
278 Posts
Re: Adding Controls to a custom user control
Feb 15, 2008 05:15 PM|LINK
Thanks for the info! What is the markup in your user control (.ascx)?
- Jesse
Please mark 'Answered' if my post was able to assist you.
achuzan
0 Points
7 Posts
Re: Adding Controls to a custom user control
Feb 15, 2008 05:57 PM|LINK
I finally gave up and am just going to have the "title bar" be a user control. So I am not using the templates at all. I think this will get me what i need. Thank you Jesse for taking the time to help me.