Hi,
I have a RadGrid that serves to show text for preview and editing. I have a detail aspx page which serves as the parent, and then user control pages within a radtabstrip with a multipageview. When I try to preview the text box within the grid (which is wihtin the usercontrol), I get a null each time I reference the window manager, the window comes back null. I have a piece of it working where I preview images, for some reason it reads tha manager fine. As you can see from the code below, I've tried a few things. Let me know if there's a viable solution to my problem. Again, informationWindowLocation works, and the OnClientPageLoad doesn't.
protected
void
ibPreviewMessage_Click(
object
sender, EventArgs e)
{
ImageButton previewMessage = (ImageButton)sender;
ClientScriptManager clientScript = Page.ClientScript;
//string clientScriptName="previewMessage";
Type clientScriptType=
this
.GetType();
int
index = previewMessage.ID.IndexOf(
"_"
), ID;
int
.TryParse(previewMessage.ID.Substring(index + 1),
out
ID);
foreach
(GridDataItem gdi
in
grdMessages.Items)
{
RadTextBox rtb = (RadTextBox)gdi[
"DefaultDescriptionNameColumn"
].FindControl(
"Description_"
+ ID.ToString());
if
(rtb !=
null
)
{
radWindowManager1.OnClientPageLoad =
"OnClientPageLoad('"
+ HttpUtility.HtmlEncode(rtb.Text) +
"')"
;
RadWindow newwindow =
new
RadWindow();
newwindow.ID =
"previewmessages"
;
newwindow.NavigateUrl =
"about:blank"
;
newwindow.VisibleOnPageLoad =
true
;
newwindow.Behaviors = WindowBehaviors.Close;
radWindowManager1.Windows.Add(newwindow);
//if (!clientScript.IsClientScriptBlockRegistered(clientScriptType, clientScriptName))
//{
// StringBuilder sb = new StringBuilder();
// sb.Append("<script type='text/javascript'>");
// sb.Append("radopen('about:blank')");
// sb.Append("document.write(" + HttpUtility.HtmlEncode(rtb.Text) + ")");
// sb.Append("</script>");
// clientScript.RegisterClientScriptBlock(clientScriptType, clientScriptName, sb.ToString());
//}
//RadAjaxManager ajm = RadAjaxManager.GetCurrent(Page);
//if (ajm != null)
//{
// ajm.Alert(HttpUtility.HtmlEncode(rtb.Text)); // make this a radopen or a window.open
//}
}
}
}
<
script
type
=
"text/javascript"
>
function informationWindowLocation(id) {
var oManager = GetRadWindowManager();
var fileName = "Images/" + id;
var examplePath = new Image();
examplePath.src = fileName;
var width = examplePath.width;
var height = examplePath.height;
var oWnd = oManager.GetWindowByName("messages");
if (width > 0 && height > 0) {
oWnd.Show();
oWnd.setSize(width + 100, height + 100);
oWnd.SetUrl(fileName, "messages");
}
else {
radalert("Example doesn't exist for this level and Promotion Type", 425, 150, "Promotion Type Example");
}
return false;
}
function OnClientPageLoad(textDescription) {
var oManager = GetRadWindowManager();
var oWnd = oManager.GetWindowByName("messages");
oWnd.GetContentFrame().contentWindow.document.write('<
html
><
title
>Preview Description</
title
><
body
>' + textDescription + '</
body
></
html
>');
oWnd.Show();
}
</
script
>
<
telerik:RadGrid
ID
=
"grdMessages"
runat
=
"server"
Skin
=
"Vista"
OnItemCreated
=
"grdMessages_ItemCreated"
style
=
"padding-top:20px;"
>
<
ItemStyle
Height
=
"150px"
/>
<
MasterTableView
AutoGenerateColumns
=
"false"
ShowHeader
=
"false"
DataKeyNames
=
"Level"
ClientDataKeyNames
=
"Level"
EnableNoRecordsTemplate
=
"true"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"Level"
UniqueName
=
"LevelColumn"
Visible
=
"false"
/>
<
telerik:GridTemplateColumn
UniqueName
=
"ShowImage"
DataField
=
"Level_Message_Example"
>
<
ItemTemplate
>
<
asp:ImageButton
ID
=
"ibPreviewLocation"
runat
=
"server"
ImageUrl
=
"~/Images/picture.png"
ImageAlign
=
"Middle"
OnClientClick='<%# String.Format("return informationWindowLocation(\"{0}\");", Eval("Level_Message_Example")) %>' />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"PreviewMessage"
DataField
=
"Level"
>
<
ItemTemplate
>
<
asp:ImageButton
ID
=
"ibPreviewMessage"
runat
=
"server"
ImageUrl
=
"~/Images/image_magnify.png"
ImageAlign
=
"Middle"
OnClick
=
"ibPreviewMessage_Click"
/>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
DataField
=
"Description"
UniqueName
=
"DescriptionColumn"
/>
<
telerik:GridTemplateColumn
DataField
=
"Default_Description"
UniqueName
=
"DefaultDescriptionNameColumn"
>
<
ItemStyle
Width
=
"70%"
Wrap
=
"false"
Height
=
"150px"
/>
<
ItemTemplate
>
<
telerik:RadTextBox
ID
=
"rtbDescription"
Height
=
"150px"
runat
=
"server"
Width
=
"100%"
TextMode
=
"MultiLine"
Text='<%# Eval("Default_Description") %>' />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
<
NoRecordsTemplate
><
asp:Label
ID
=
"lblPromotionEmptyMessage"
runat
=
"server"
Text
=
"No Messages Available for Editing"
/></
NoRecordsTemplate
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
telerik:RadWindowManager
ID
=
"radWindowManager1"
runat
=
"server"
></
telerik:RadWindowManager
>
the radwindow manager on the aspx page looks like this
I know that it has two radwindowmanagers on the same page, but I couldn't get the manager from the main page when I tried to search using the $find method. I also couldn't find the one on the user control. Let me know if there is anything I should do. Thanks