I experienced a problem migrating from RadControls for ASP.NET Q3 2007 with Hotfix to ASP.NET for AJAX Q1 2008.
The following code is responsible for registering a new client java script block, which works. It also hooks the client side events. m_Instance is a RadGrid in this case.
The problem going from the Telerik RadControls Q32007 Hotfix version to the ASP.NET AJAX Q1 2008 release involves the rendered client page and the ProcessSelectedItemsBatch function not being defined.
The resulted rendered page contains:
defined towards the top of the page
and
towards the bottom of the page.
the $create method's events array contains two items, but the value containing the function is undefined for both items.
I am using a RadScriptManager which is serving up the javascript properly, I think.
But I figure that despite the function being defined within the apparent scope, I am doing something incorrectly and minimally will need to change how I am registering the client script.
Do I need to use a RadScriptBlock instead of or in addition to the ClientScriptManager? Or something else?
I would appreciate any guidance.
Thanks,
Kyle
The following code is responsible for registering a new client java script block, which works. It also hooks the client side events. m_Instance is a RadGrid in this case.
| ClientScriptManager cs = m_Instance.Page.ClientScript; |
| string pb = String.Empty; |
| if (!cs.IsClientScriptBlockRegistered(this.GetType(), "ProcessSelectedItemsBatch")) |
| { |
| pb = cs.GetPostBackEventReference(this, "***"); |
| StringBuilder cstext = new StringBuilder(); |
| cstext.Append("<script type=\"text/javascript\">"); |
| cstext.Append("function ProcessSelectedItemsBatch(sender)"); |
| cstext.Append("{"); |
| cstext.Append(pb.Replace("'***'", "sender")); |
| cstext.Append("}"); |
| cstext.AppendLine("</script>"); |
| cs.RegisterClientScriptBlock(this.GetType(), "ProcessSelectedItemsBatch", cstext.ToString(), false); |
| } |
| String call = String.Format("ProcessSelectedItemsBatch('{0}')", m_ScreenPart.GID.ToString()); |
| this.m_Instance.Attributes.Add("onblur", call); |
| this.m_Instance.MasterTableView.Attributes.Add("onblur", call); |
| this.m_Instance.ClientSettings.ClientEvents.OnRowSelected = call; |
| this.m_Instance.ClientSettings.ClientEvents.OnRowDeselected = call; |
The problem going from the Telerik RadControls Q32007 Hotfix version to the ASP.NET AJAX Q1 2008 release involves the rendered client page and the ProcessSelectedItemsBatch function not being defined.
The resulted rendered page contains:
| <script type="text/javascript">function ProcessSelectedItemsBatch(sender){__doPostBack('ctl00$CPBody$_se$ctl12',sender)}</script> |
defined towards the top of the page
and
| Sys.Application.add_init(function() { |
| $create(Telerik.Web.UI.RadGrid, {"AllowMultiRowSelection":true,"ClientID":"ctl00_CPBody__se_screen__04e3347b33fa41e68b37a936cef7eee6","ClientSettings":{"PostBackFunction":"__doPostBack(\u0027{0}\u0027,\u0027{1}\u0027)","AllowDragToGroup":true,"AllowExpandCollapse":true,"AllowGroupExpandCollapse":true,"ColumnsReorderMethod":0,"ShouldCreateRows":true,"Selecting":{"AllowRowSelect":true,"EnableDragToSelectRows":true},"Scrolling":{"SaveScrollPosition":true,"ScrollHeight":"300px"},"Resizing":{"ClipCellContentOnResize":true},"ClientMessages":{"DragToGroupOrReorder":"Drag to group or reorder","DragToResize":"Drag to resize","DropHereToReorder":"Drop here to reorder","PagerTooltipFormatString":"Page: \u003cb\u003e{0}\u003c/b\u003e out of \u003cb\u003e{1}\u003c/b\u003e pages"}},"ShowGroupPanel":true,"Skin":"Default","UniqueID":"ctl00$CPBody$_se$screen__04e3347b33fa41e68b37a936cef7eee6","_activeRowData":"","_clientKeyValues":{},"_currentPageIndex":0,"_gridTableViewsData":"[{\"ClientID\":\"ctl00_CPBody__se_screen__04e3347b33fa41e68b37a936cef7eee6_ctl00\",\"UniqueID\":\"ctl00$CPBody$_se$screen__04e3347b33fa41e68b37a936cef7eee6$ctl00\",\"PageSize\":10,\"PageCount\":1,\"CurrentPageIndex\":0,\"Name\":\"\",\"IsItemInserted\":false,\"clientDataKeyNames\":[],\"_selectedItemStyle\":\"\",\"_selectedItemStyleClass\":\"SelectedRow_Default\",\"_renderActiveItemStyle\":\"\",\"_renderActiveItemStyleClass\":\"ActiveRow_Default\",\"_columnsData\":[{\"UniqueName\":\"GID\",\"Resizable\":true,\"Reorderable\":true,\"Groupable\":true,\"Display\":false},{\"UniqueName\":\"TaxID\",\"Resizable\":true,\"Reorderable\":true,\"Groupable\":true,\"Display\":true},{\"UniqueName\":\"GivenName\",\"Resizable\":true,\"Reorderable\":true,\"Groupable\":true,\"Display\":true},{\"UniqueName\":\"Surname\",\"Resizable\":true,\"Reorderable\":true,\"Groupable\":true,\"Display\":true},{\"UniqueName\":\"DateOfBirth\",\"Resizable\":true,\"Reorderable\":true,\"Groupable\":true,\"Display\":true},{\"UniqueName\":\"GenderID\",\"Resizable\":true,\"Reorderable\":true,\"Groupable\":true,\"Display\":true}]}]","_groupPanelClientID":"ctl00_CPBody__se_screen__04e3347b33fa41e68b37a936cef7eee6_GroupPanel_TB","_groupPanelItems":"[]","_loadingText":"Loading...","_masterClientID":"ctl00_CPBody__se_screen__04e3347b33fa41e68b37a936cef7eee6_ctl00","_popUpIds":"[]","_readyText":"Ready","_statusLabelID":"","clientStateFieldID":"ctl00_CPBody__se_screen__04e3347b33fa41e68b37a936cef7eee6_ClientState"}, {"rowDeselected":ProcessSelectedItemsBatch('04e3347b-33fa-41e6-8b37-a936cef7eee6'),"rowSelected":ProcessSelectedItemsBatch('04e3347b-33fa-41e6-8b37-a936cef7eee6')}, null, $get("ctl00_CPBody__se_screen__04e3347b33fa41e68b37a936cef7eee6")); |
towards the bottom of the page.
the $create method's events array contains two items, but the value containing the function is undefined for both items.
I am using a RadScriptManager which is serving up the javascript properly, I think.
But I figure that despite the function being defined within the apparent scope, I am doing something incorrectly and minimally will need to change how I am registering the client script.
Do I need to use a RadScriptBlock instead of or in addition to the ClientScriptManager? Or something else?
I would appreciate any guidance.
Thanks,
Kyle