Hi I have a RadWindow Generated at runtime based on certain condition , it also attaches itself to the RadWindowManager...
On first page load, the ID is set to "wndSetUp"... and on that page i have a button, when i click on the button to execute an onclick to display the radwindow, it postback , so on the next page load, i try to find the RadWindow using the FindControl("wndSetUp") but coudlnt find it... it turned out the ID has changed to a defaut "ctl02" rather than "wndSetUp" ( which it was correct on first page load)...
In the Watch Window, the ID clearly changes when I click on the button.
Can anyone explain to me why the ID?
On My PageBASE class, inheritted by my pages, it checks a wnSetUp needs to be created using the 3 conditions: NeedUserSetUp, IsValidContext and !IsPostBack. My Work around is tp force a new creation of "wndSetUp" RadWindow (by removing the !IsPOstBack)... but in the end i had 2 RadWindows ( one with "ct02" and the other one since I recreated it on the postback with "wndSetUp")
On first page load, the ID is set to "wndSetUp"... and on that page i have a button, when i click on the button to execute an onclick to display the radwindow, it postback , so on the next page load, i try to find the RadWindow using the FindControl("wndSetUp") but coudlnt find it... it turned out the ID has changed to a defaut "ctl02" rather than "wndSetUp" ( which it was correct on first page load)...
In the Watch Window, the ID clearly changes when I click on the button.
Can anyone explain to me why the ID?
Code of Master Page which has the onClick Button
protected void Page_Load(object sender, EventArgs e)
{
//Check if Calling Pages Require New User Set Up
if (SessionContext.NeedUserSetUp)
{
// Find Reference to Window Set Up
RadWindow wndSetUp = GetUserSetUpWindow();
if (wndSetUp != null)
{// Show Set Up Button and Add Ajax Settings
btNewUserSetUp.Visible = true;
RadAjaxManager_GM.AjaxSettings.AddAjaxSetting(btNewUserSetUp, wndSetUp);
}
else
{
btNewUserSetUp.Visible = false;
}
}
else
{
btNewUserSetUp.Visible = false;
}
}
/// <
summary
>
/// Handles the Click event of the btNewUserSetUp control.
/// </
summary
>
/// <
param
name
=
"sender"
>The source of the event.</
param
>
/// <
param
name
=
"e"
>The <
see
cref
=
"System.EventArgs"
/> instance containing the event data.</
param
>
protected void btNewUserSetUp_Click(object sender, EventArgs e)
{
RadWindow wndSetup = GetUserSetUpWindow();
if (wndSetup != null)
{
wndSetup.Visible = true;
wndSetup.VisibleOnPageLoad = true;
}
}
/// <
summary
>
/// Gets the user set up window. Find the Reference to the Window Set Up generated dynamically
/// </
summary
>
/// <
returns
></
returns
>
private RadWindow GetUserSetUpWindow()
{
switch (sectionName)
{
case "SavingsCenter":
case "ShoppingLists":
case "BrowseItems":
case "FindDeals":
default:
return (RadWindow)Page.Form.FindControl("RadWindowManager_GM").FindControl("wndSetUp");
}
}
HTML
<
telerik:RadWindowManager
ID
=
"RadWindowManager_GM"
runat
=
"server"
>
</
telerik:RadWindowManager
>
<
telerik:RadButton
ID
=
"btNewUserSetUp"
runat
=
"server"
Visible
=
"false"
Width
=
"98"
Height
=
"21"
OnClick
=
"btNewUserSetUp_Click"
>
<
Image
ImageUrl
=
"../Images/btNewUserSetUp.gif"
HoveredImageUrl
=
"../Images/btNewUserSetUp_up.gif"
/>
</
telerik:RadButton
>
On My PageBASE class, inheritted by my pages, it checks a wnSetUp needs to be created using the 3 conditions: NeedUserSetUp, IsValidContext and !IsPostBack. My Work around is tp force a new creation of "wndSetUp" RadWindow (by removing the !IsPOstBack)... but in the end i had 2 RadWindows ( one with "ct02" and the other one since I recreated it on the postback with "wndSetUp")
protected override void OnLoad(EventArgs e)
{
_SessionContext.CallingPage = this;
//Check for New User Set Up
if (SessionContext.NeedUserSetUp && IsValidContext() && !IsPostBack)
{
RadWindow wndSetUp = CreateNewUserSetUpWindow(true);
}
base.OnLoad(e);
}
/// <
summary
>
/// Determines whether [is valid context] only if PageBase called within the ApplicationLayer.
/// </
summary
>
/// <
returns
>
/// <
c
>true</
c
> if [is valid context]; otherwise, <
c
>false</
c
>.
/// </
returns
>
private bool IsValidContext()
{
MasterPage master = GetRootLevelMaster();
return (master != null ? (master.GetType().Name.IndexOf("applicationlayer") > 0) : false);
}
/// <
summary
>
/// Creates the new user set up window.
/// </
summary
>
/// <
param
name
=
"manualSetUp"
>if set to <
c
>true</
c
> [manual set up].</
param
>
/// <
returns
></
returns
>
public RadWindow CreateNewUserSetUpWindow(bool manualSetUp)
{
RadWindow wndSetUp = new RadWindow();
WindowSetUpConfigurations(wndSetUp, manualSetUp);
RadWindowManager wndManager = (RadWindowManager)GetWindowManager();
wndManager.Windows.Add(wndSetUp);
//Attach RadWindow to the Form
//this.Page.Form.Controls.Add(wndSetUp);
return wndSetUp;
}
private Control GetWindowManager()
{
MasterPage master = GetRootLevelMaster();
return master.FindControl("RadWindowManager_GM");
}
private MasterPage GetRootLevelMaster()
{
MasterPage master = Page.Master;
MasterPage prevMaster = null;
while (master != null)
{
prevMaster = master;
master = master.Master;
}
return prevMaster;
}
/// <
summary
>
/// Windows the set up configurations.
/// Requirement: CSS Skin is loaded for RadWindow in Master
/// </
summary
>
/// <
param
name
=
"wndSetUp"
>The WND set up.</
param
>
private void WindowSetUpConfigurations(RadWindow wndSetUp,bool manualSetUp)
{
wndSetUp.ID = "wndSetUp";
if (manualSetUp)
{
RadButton btSetUp = (RadButton)GetWindowManager().FindControl("btNewUserSetUp");
wndSetUp.OpenerElementID = btSetUp.ClientID;
}
wndSetUp.Title = "First Time Setup";
wndSetUp.Skin = "gmBlue";
wndSetUp.NavigateUrl = "../Pages/InitialSetUp.aspx";
wndSetUp.Height = 730;
wndSetUp.Width = 900;
wndSetUp.KeepInScreenBounds = true;
wndSetUp.Modal = true;
wndSetUp.Overlay = true;
wndSetUp.ShowContentDuringLoad = true;
wndSetUp.Visible = false;
wndSetUp.VisibleStatusbar = false;
wndSetUp.VisibleTitlebar = true;
wndSetUp.Behaviors = WindowBehaviors.Close | WindowBehaviors.Move;
wndSetUp.EnableEmbeddedSkins = false;
wndSetUp.EnableShadow = false;
}