Solved

PlaceHolder control not working

Posted on 2006-06-17
5
431 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

717 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