Solved

PlaceHolder control not working

Posted on 2006-06-17
5
400 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

911 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

18 Experts available now in Live!

Get 1:1 Help Now