Is it possible to add a System.Web.UI.UserControl in an asp:PlaceHolder
-
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 commandplhMessage.Controls.Add(mb);
it goes in to theprotected 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 -
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 commandplhMessage.Controls.Add(mb);
it goes in to theprotected 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. ThomasYou 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
-
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 commandplhMessage.Controls.Add(mb);
it goes in to theprotected 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. ThomasYou can't use MessageBox in ASP.NET applications. You'll have to resort to javascript
alert
orconfirm
or create your own popup.Cheers, Mircea "Pay people peanuts and you get monkeys" - David Ogilvy