Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Is it possible to add a System.Web.UI.UserControl in an asp:PlaceHolder

Is it possible to add a System.Web.UI.UserControl in an asp:PlaceHolder

Scheduled Pinned Locked Moved ASP.NET
designquestionlearning
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    thomasa
    wrote on last edited by
    #1

    I want to create a MessageBox, that I want to use on many of my web pages. The MessageBox is a System.Web.UI.UserControl and is an .ascx file. It contains a table with som labels in it. Now on my UserEdit.aspx site I've added an asp:PlaceHolder with ID="plhMessage". At the code behind I want to add a messagebox, something like: plhMessage.Visible = true; MyMessageBox mb = new MyMessageBox(); mb.Type = global::My.Web.Controls.MyMessageBox.EnumMessageType.Ok; mb.MessageText = "Data was saved."; plhMessage.Controls.Add(mb); Now at the command plhMessage.Controls.Add(mb); it goes in to the protected void Page_Load(object sender, EventArgs e) of the MyMessageBox control. But when I look at any of the Label properies it is NULL. The result is of course that there is no message to view. What am I doing wrong? Or is there a better way of doing this in VisualStudio 2005? (maybe somthing like an asp:Content, asp:ContentPlaceHolder witch I'm using on my masterpage) I've easely done this with controls of type "WebControl", but then I've had to create all the items with codelines, and I want the flexability an System.Web.UI.UserControl gives with reference to design layout. Thank you. Thomas

    K M 2 Replies Last reply
    0
    • T thomasa

      I want to create a MessageBox, that I want to use on many of my web pages. The MessageBox is a System.Web.UI.UserControl and is an .ascx file. It contains a table with som labels in it. Now on my UserEdit.aspx site I've added an asp:PlaceHolder with ID="plhMessage". At the code behind I want to add a messagebox, something like: plhMessage.Visible = true; MyMessageBox mb = new MyMessageBox(); mb.Type = global::My.Web.Controls.MyMessageBox.EnumMessageType.Ok; mb.MessageText = "Data was saved."; plhMessage.Controls.Add(mb); Now at the command plhMessage.Controls.Add(mb); it goes in to the protected void Page_Load(object sender, EventArgs e) of the MyMessageBox control. But when I look at any of the Label properies it is NULL. The result is of course that there is no message to view. What am I doing wrong? Or is there a better way of doing this in VisualStudio 2005? (maybe somthing like an asp:Content, asp:ContentPlaceHolder witch I'm using on my masterpage) I've easely done this with controls of type "WebControl", but then I've had to create all the items with codelines, and I want the flexability an System.Web.UI.UserControl gives with reference to design layout. Thank you. Thomas

      K Offline
      K Offline
      kubben
      wrote on last edited by
      #2

      You can always use javascript it is a little easier. (.net 2.0)

      private void ShowDialog(string p_msg)
      {
      Type cstype = this.GetType();
      StringBuilder tmpSB = new StringBuilder();
      tmpSB.Append("");

      tmpSB.Append("alert('" + p_msg + "')");
      tmpSB.Append("");
      ClientScript.RegisterClientScriptBlock(cstype, "Save", tmpSB.ToString());
      }

      Ben

      1 Reply Last reply
      0
      • T thomasa

        I want to create a MessageBox, that I want to use on many of my web pages. The MessageBox is a System.Web.UI.UserControl and is an .ascx file. It contains a table with som labels in it. Now on my UserEdit.aspx site I've added an asp:PlaceHolder with ID="plhMessage". At the code behind I want to add a messagebox, something like: plhMessage.Visible = true; MyMessageBox mb = new MyMessageBox(); mb.Type = global::My.Web.Controls.MyMessageBox.EnumMessageType.Ok; mb.MessageText = "Data was saved."; plhMessage.Controls.Add(mb); Now at the command plhMessage.Controls.Add(mb); it goes in to the protected void Page_Load(object sender, EventArgs e) of the MyMessageBox control. But when I look at any of the Label properies it is NULL. The result is of course that there is no message to view. What am I doing wrong? Or is there a better way of doing this in VisualStudio 2005? (maybe somthing like an asp:Content, asp:ContentPlaceHolder witch I'm using on my masterpage) I've easely done this with controls of type "WebControl", but then I've had to create all the items with codelines, and I want the flexability an System.Web.UI.UserControl gives with reference to design layout. Thank you. Thomas

        M Offline
        M Offline
        Mircea Grelus
        wrote on last edited by
        #3

        You can't use MessageBox in ASP.NET applications. You'll have to resort to javascript alert or confirm or create your own popup.

        Cheers, Mircea "Pay people peanuts and you get monkeys" - David Ogilvy

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups