Solved

PlaceHolder control not working

Posted on 2006-06-17
5
390 Views
Last Modified: 2008-03-10
I have a problem with a user control not working with a place holder control.   Here is my code

----- aspx file
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="test1.aspx.vb" Inherits="WebApplication4.test1"%>
<%@ Register TagPrefix="cc1" Namespace="Dart.PowerWEB.LiveControls" Assembly="Dart.PowerWEB.LiveControls" %>
<%@ Reference Control="tstcontrol.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
      <HEAD>
            <title>test1</title>
            <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
            <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
            <meta content="JavaScript" name="vs_defaultClientScript">
            <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
      </HEAD>
      <body MS_POSITIONING="GridLayout">
            <form id="Form1" method="post" runat="server">
                  <asp:PlaceHolder id="PlaceHolder1" runat="server"></asp:PlaceHolder></form>
      </body>
</HTML>
---aspx code behind
  Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        If Not IsPostBack Then
            Dim a As tstcontrol
            a = New tstcontrol
            Me.PlaceHolder1.Controls.Add(a)


        End If
    End Sub

----user control HTML
<%@ Control Language="vb"  AutoEventWireup="false" Codebehind="tstcontrol.ascx.vb" Inherits="WebApplication4.tstcontrol" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<%@ Register TagPrefix="cc1" Namespace="Dart.PowerWEB.LiveControls" Assembly="Dart.PowerWEB.LiveControls" %>
 
<P>yo yo yo yo yo</P>

There is no code behind in the web control.  When I run the app I get nothing in the aspx page in my browser.

Thanks for the help.
0
Comment
Question by:Gawron3
  • 3
  • 2
5 Comments
 
LVL 7

Expert Comment

by:kGenius
ID: 16928693
Remove the <%@ Register TagPrefix="cc1" Namespace="Dart.PowerWEB.LiveControls" Assembly="Dart.PowerWEB.LiveControls" %>
in your user control.
maybe this will help. You register a tag of the user control in the user control itself...

kGenius
0
 

Author Comment

by:Gawron3
ID: 16929666
Thanks for the suggestion but that didnt work...


0
 
LVL 7

Accepted Solution

by:
kGenius earned 500 total points
ID: 16929689
Your control must be loaded I think. since you referenced your control but not Registered it

in Page_Load of your aspx page

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        If Not IsPostBack Then
            Dim a As tstcontrol=LoadControl("txtcontrol.ascx")
            Me.PlaceHolder1.Controls.Add(a)

        End If
End Sub

The "<%@ Register TagPrefix="cc1" Namespace="Dart.PowerWEB.LiveControls" Assembly="Dart.PowerWEB.LiveControls" %>" must remain. My excuses for that one...

kGenius
0
 
LVL 7

Expert Comment

by:kGenius
ID: 16929693
LoadControl("txtcontrol.ascx") must be LoadControl("tstcontrol.ascx") (or the path where your control is)
0
 

Author Comment

by:Gawron3
ID: 16930955
Thanks a bunch for your help...:)
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now