?
Solved

PlaceHolder control not working

Posted on 2006-06-17
5
Medium Priority
?
440 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 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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 …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses
Course of the Month15 days, 17 hours left to enroll

850 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