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);
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi Rabih,
I am not sure why it does that. Can you create a sample app that demonstrates the problem?
Thanks
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
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
|