Hello everyone,
I am trying to open a RadWindow from a custom field type and return a value from the user. The window is supposed to be opened from the custom field (see openSearchDialogButton below) that is implemented as a user control (CustomControl.ascx in ControlTemplates). The code for this control is encapsulated in an assembly deployed to the GAC.
The user control is defined as follows:
The page loaded within the RadWindow has the following definition:
Finally, the code-behind for the page:
Clicking the GridHyperLinkColumn returns the selected value as an argument to returnToParent.
The problem I am facing is that the call to radopen fails with the error "radopen is not defined" (Firebug). While I've got this working in a standard ASP.NET project it just won't work with SharePoint. Any clues?
Thank you
Steve
I am trying to open a RadWindow from a custom field type and return a value from the user. The window is supposed to be opened from the custom field (see openSearchDialogButton below) that is implemented as a user control (CustomControl.ascx in ControlTemplates). The code for this control is encapsulated in an assembly deployed to the GAC.
The user control is defined as follows:
| <%@ Control Language="C#" Debug="True" %> |
| <%@ Assembly Name="Pl.ContractCenter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1d55543c9f6e51cd" %> |
| <%@ Assembly Name="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %> |
| <%@ Register TagPrefix="SharePoint" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.WebControls"%> |
| <%@ Register Assembly="Telerik.Web.UI, Version=2009.1.402.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
| <SharePoint:RenderingTemplate ID="PlSearchFieldControl" runat="server"> |
| <Template> |
| <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager> |
| <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> |
| <script language="javascript" type="text/javascript"> |
| //<![CDATA[ |
| function openWin() { |
| var oWnd = radopen("/_layouts/PlSearchCompanyForm.aspx", "RadWindow1"); |
| } |
| function OnClientClose(oWnd, args) { |
| var arg = args.get_argument(); |
| if (arg) { |
| var companyNo = arg.companyNo; |
| var o = $get(txtAddValueId); // set in code-behind |
| if (o) |
| o.value = companyNo; |
| } |
| } |
| //]]> |
| </script> |
| </telerik:RadCodeBlock> |
| <telerik:RadAjaxManager runat="server" ID="RadAjaxManager1" EnableAJAX="true" > |
| <AjaxSettings> |
| <telerik:AjaxSetting AjaxControlID="btnAdd"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="companyNo" /> |
| <telerik:AjaxUpdatedControl ControlID="companyName" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| <telerik:AjaxSetting AjaxControlID="deleteButton"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="companyNo" /> |
| <telerik:AjaxUpdatedControl ControlID="companyName" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| </AjaxSettings> |
| </telerik:RadAjaxManager> |
| <telerik:RadAjaxPanel runat="server"> |
| <asp:GridView ID="grdChoices" runat="server" Width="90%" AutoGenerateDeleteButton="True" ShowHeader="false" BorderWidth="0" BorderStyle="None"> |
| <RowStyle CssClass="ms-vb2" /> |
| </asp:GridView> |
| </telerik:RadAjaxPanel> |
| <br /> |
| <a runat="server" ID="openSearchDialogButton" onclick="openWin(); return false;"><img src="/_layouts/images/gosearch.gif" runat="server" id="imgSearch" border="0" alt="search" /></a> |
| <asp:TextBox CssClass="ms-input" ID="txtAddValue" runat="server"/> |
| <asp:Button CssClass="ms-input" ID="btnAdd" runat="server" Text="Add" /><br /> |
| <asp:CustomValidator ID="validGlobal" runat="server" Display="Dynamic"></asp:CustomValidator> |
| <telerik:RadWindowManager ID="RadWindowManager1" ShowContentDuringLoad="false" VisibleStatusbar="false" ReloadOnShow="true" runat="server" Skin="Sunset"> |
| <Windows> |
| <telerik:RadWindow ID="RadWindow1" runat="server" Behaviors="Close" OnClientClose="OnClientClose" NavigateUrl="/_layouts/PlSearchCompanyForm.aspx" Width="600" Height="500"></telerik:RadWindow> |
| </Windows> |
| </telerik:RadWindowManager> |
| </Template> |
| </SharePoint:RenderingTemplate> |
The page loaded within the RadWindow has the following definition:
| <%@ Page Language="C#" AutoEventWireup="true" Inherits="Pl.ContractCenter.UI.Pages.SearchCompanyForm, Pl.ContractCenter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1d55543c9f6e51cd" %> |
| <%@ Assembly Name="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %> |
| <%@ Register Assembly="Telerik.Web.UI, Version=2009.1.402.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head runat="server"> |
| <title>Search for Companies</title> |
| </head> |
| <body> |
| <form id="form1" runat="server"> |
| <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager> |
| <telerik:RadCodeBlock runat="server" ID="RadCodeBlock1" > |
| <script language="javascript" type="text/javascript"> |
| function GetRadWindow() { |
| var oWindow = null; |
| if (window.radWindow) |
| oWindow = window.radWindow; |
| else if (window.frameElement.radWindow) |
| oWindow = window.frameElement.radWindow; |
| return oWindow; |
| } |
| function returnToParent(companyNo) { |
| var oArg = new Object(); |
| oArg.companyNo = companyNo; |
| var oWnd = GetRadWindow(); |
| if(oArg.companyNo) { |
| oWnd.close(oArg); |
| } |
| } |
| </script> |
| </telerik:RadCodeBlock> |
| <div> |
| <telerik:RadTextBox runat="server" ID="searchTextBox" /> |
| <asp:Button runat="server" ID="searchButton" onclick="searchButton_Click" /> |
| <telerik:RadGrid runat="server" ID="RadGrid1" DataSourceID="odsCompany" AutoGenerateColumns="False" GridLines="None" AllowPaging="True" onitemdatabound="RadGrid1_ItemDataBound"> |
| <MasterTableView DataSourceID="odsCompany" DataKeyNames="CompanyNo"> |
| <RowIndicatorColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </RowIndicatorColumn> |
| <ExpandCollapseColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </ExpandCollapseColumn> |
| <Columns> |
| <telerik:GridBoundColumn DataField="CompanyFullName" HeaderText="Company Name" SortExpression="CompanyByName" UniqueName="CompanyByName"> |
| </telerik:GridBoundColumn> |
| <telerik:GridHyperLinkColumn DataTextField="CompanyNo" HeaderText="Number" SortExpression="CompanyNo" UniqueName="CompanyNo"> |
| </telerik:GridHyperLinkColumn> |
| </Columns> |
| </MasterTableView> |
| </telerik:RadGrid> |
| <asp:ObjectDataSource> |
| <%-- SNIPPED --%> |
| </asp:ObjectDataSource> |
| </div> |
| </form> |
| </body> |
| </html> |
Finally, the code-behind for the page:
| public class SearchCompanyForm : Page { |
| protected ObjectDataSource odsCompany; |
| protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) { |
| try { |
| if (e.Item is GridDataItem) { |
| var hyperLink = (e.Item as GridDataItem)["CompanyNo"].Controls[0] as HyperLink; |
| if (hyperLink == null) |
| return; |
| hyperLink.NavigateUrl = "#"; |
| hyperLink.Attributes.Add("OnClick", String.Format("javascript:returnToParent({0}); return false;", hyperLink.Text.Trim())); |
| } |
| } catch (Exception exception) { |
| Console.WriteLine(exception.Message); |
| } |
| } |
| protected void searchButton_Click(object sender, EventArgs e) { |
| odsCompany.Select(); |
| } |
| } |
Clicking the GridHyperLinkColumn returns the selected value as an argument to returnToParent.
The problem I am facing is that the call to radopen fails with the error "radopen is not defined" (Firebug). While I've got this working in a standard ASP.NET project it just won't work with SharePoint. Any clues?
Thank you
Steve