Solved

PlaceHolder control not working

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Convert Select to DropDownListFor MVC 5 2 48
jquery + C#.net radiobuttonlist 3 46
How to repeat the data 4 30
orderby list (from Json) 1 31
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…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

730 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