Welcome Guest Search | Active Topics | Sign In | Register

How to create more than 1 dialog from server side dynamically? Options
Rabih
Posted: Sunday, July 15, 2007 2:40:49 AM
Rank: Member
Groups: Member

Joined: 6/24/2007
Posts: 14
Hello,
I have a control where i am trying to open more than one dialog dynamically without pre-creating them in aspx, or ascx file, I have succeeded to do so, but everytime the new dialog opens the old one closes, bearing in mind that they are having different ids. please find attached my code, where is my mistake?
Code: C#
Dialog dynDialog = new Dialog();
            dynDialog.ID = e.CategoryId.ToString();
            dynDialog.ControlSkinID = "None";
            dynDialog.Width = 1000;
            dynDialog.Height = 500;
            dynDialog.HeaderHtml = "Search Dialog for" + e.CategoryId.ToString();
            dynDialog.BorderStyle = BorderStyle.Solid;
            dynDialog.CloseButtonUrl = "00070101";
            dynDialog.MinimizeButtonUrl = "00070102";
            dynDialog.AllowResize = true;
            dynDialog.BorderWidth = 1;
            //dynDialog.BorderColor = Color.FromArgb(335C88);
            dynDialog.RestoreButtonUrl = "00070103";
            dynDialog.ShadowDepth = 3;
            dynDialog.ResizeImageUrl = "00020014";
            String strURL;
            strURL = @"Search.aspx?c=" + e.CategoryId.ToString() + "&Type=1";// +StrTypeField.Value.ToString();
            dynDialog.ContentUrl = strURL.ToString();
            dynDialog.ShowButton = e.CategoryId.ToString();
            dynDialog.HeaderStyleActive.CssText = "padding-right: 4px; padding-left: 4px; font-size: 11px; background-image: url(00070104); padding-bottom: 3px; padding-top: 3px; font-family: tahoma";
            dynDialog.InitialState = DialogState.Visible;
            dynDialog.IsModal = false;
            Panel1.Controls.Add(dynDialog);
eo_support
Posted: Sunday, July 15, 2007 4:45:08 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi Rabih,

I am not sure why it does that. Can you create a sample app that demonstrates the problem?

Thanks
eo_support
Posted: Tuesday, July 17, 2007 12:45:20 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi Rabih,

We looked into your code and what's happening is very normal. The issue has nothing to do with our Dialog control. Controls dynamically created during one postback will NOT stay beyound the current page cycle. When you have two LinkButtons that create separates dialogs, what you created during previous request will not reappear during the current request.

One of the biggest benefits of ASP.NET is ViewState support. ViewState gives you the false impression that everything created by code will be persisted. That is false. ViewState is supported by Controls, if the Controls are not there at the first place; ViewState has nothing to "stick" to. This is often being overlooked because by default, every control is created based on a static .aspx file, so the controls are "always there". It's a totally different story when you create controls dynamically. The generally rule is, if you create them dynamically; make sure you re-create them appropriately.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.