| <%@ Master Language="C#" AutoEventWireup="true" Codebehind="WebAppMaster.master.cs" |
| Inherits="Portal.Shell.MasterPages.WebAppMaster" %> |
| <%@ Register Assembly="Telerik.Web.UI" 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 id="Head" runat="server"> |
| <title></title> |
| <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> |
| <meta name="description" content="" /> |
| <meta name="keywords" content="" /> |
| <meta name="author" content="" /> |
| </head> |
| <body> |
| <div id="wrap"> |
| <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecoratedControls="All" /> |
| <form id="mainForm" runat="server"> |
| <asp:ScriptManager ID="DefaultMasterScriptManager" runat="server"></asp:ScriptManager> |
| <asp:ContentPlaceHolder ID="DefaultContent" runat="server" /> |
| <br /><br /> |
| </form> |
| </div> |
| </body> |
| </html> |
| <%@ Page Language="C#" AutoEventWireup="true" Codebehind="Domains.aspx.cs" Inherits="Portal.WebApp.Views.Domains" |
| Title="Domains" MasterPageFile="~/Shared/WebAppMaster.master" %> |
| <%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> |
| <asp:Content ID="content" ContentPlaceHolderID="DefaultContent" Runat="Server"> |
| <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> |
| <script type="text/javascript"> |
| function pageLoad(sender, eventArgs) { |
| if (!eventArgs.get_isPartialLoad()) { |
| $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("InitialPageLoad"); |
| } |
| } |
| </script> |
| </telerik:RadCodeBlock> |
| <script type="text/javascript"> |
| var currentTooltip = null; |
| function OnClientBeforeShow(sender, args) { |
| //Hide the currently visible tooltip |
| if (currentTooltip) { |
| if (currentTooltip != sender) currentTooltip.hide(); |
| return; |
| } |
| currentTooltip = sender; |
| args.set_cancel(true); |
| } |
| function centerTooltip(img) { |
| if (currentTooltip) { |
| currentTooltip.set_contentElement(img); |
| //use the method updateLocation because it does not call WebService's method which loads the content |
| currentTooltip.updateLocation(); |
| currentTooltip = null; |
| } |
| } |
| </script> |
| <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" |
| OnAjaxRequest="RadAjaxManager1_AjaxRequest"> |
| <AjaxSettings> |
| <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="Panel1" |
| LoadingPanelID="RadAjaxLoadingPanel1" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| </AjaxSettings> |
| </telerik:RadAjaxManager> |
| <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="75px" |
| Width="75px"> |
| <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading3.gif") %>' |
| style="border: 0px;" /> |
| </telerik:RadAjaxLoadingPanel> |
| <telerik:RadToolTipManager ID="RadToolTipManager1" runat="server" Position="center" |
| RelativeTo="BrowserWindow" OnClientBeforeShow="OnClientBeforeShow"> |
| <WebServiceSettings Method="GetWebSiteThumb" Path="~/Services/WSSiteThumb.asmx" /> |
| </telerik:RadToolTipManager> |
| <h2>Domains</h2> |
| <asp:Panel ID="Panel1" runat="server"> |
| <div class="breadcrumb">Back to: <a href="Default.aspx">Jobs</a></div> |
| <telerik:RadGrid ID="RadGrid1" runat="server" |
| AllowSorting="True" GridLines="None" AutoGenerateColumns="false" OnItemCommand="RadGrid1_OnItemCommand" OnItemDataBound="RadGrid1_ItemDataBound"> |
| <ClientSettings EnableRowHoverStyle="true"> |
| <Selecting AllowRowSelect="false" /> |
| </ClientSettings> |
| <MasterTableView CellSpacing="-1"> |
| <RowIndicatorColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </RowIndicatorColumn> |
| <ExpandCollapseColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </ExpandCollapseColumn> |
| <Columns> |
| <telerik:GridTemplateColumn UniqueName="thumb" ItemStyle-Width="20px"> |
| <ItemTemplate> |
| <asp:Image runat="server" ID="thumb" ImageUrl="" Width="16" Height="16" /> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridBoundColumn UniqueName="domain" DataField="domain" HeaderText="Domain"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn UniqueName="score" DataField="score" HeaderText="Score"> |
| </telerik:GridBoundColumn> |
| <telerik:GridButtonColumn CommandName="Select" Text="View Pages" |
| UniqueName="select" HeaderText="Action"> |
| </telerik:GridButtonColumn> |
| </Columns> |
| </MasterTableView> |
| </telerik:RadGrid> |
| </asp:Panel> |
| </asp:Content> |
| using System; |
| using System.Data; |
| using System.Configuration; |
| using System.Collections; |
| using System.Web; |
| using System.Web.Security; |
| using System.Web.UI; |
| using System.Web.UI.WebControls; |
| using System.Web.UI.WebControls.WebParts; |
| using System.Web.UI.HtmlControls; |
| using Portal.WebApp.Views; |
| using Microsoft.Practices.ObjectBuilder; |
| using System.Collections.Generic; |
| using Portal.BusinessObjects.Interface; |
| using Telerik.Web.UI; |
| namespace Portal.WebApp.Views |
| { |
| public partial class Domains : Microsoft.Practices.CompositeWeb.Web.UI.Page, IDomainsView |
| { |
| private DomainsPresenter _presenter; |
| protected void Page_Load(object sender, EventArgs e) |
| { |
| if (!this.IsPostBack) |
| { |
| //this._presenter.OnViewInitialized(); |
| } |
| this._presenter.OnViewLoaded(); |
| } |
| protected void RadAjaxManager1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e) |
| { |
| if (e.Argument == "InitialPageLoad") |
| { |
| this._presenter.OnViewInitialized(); |
| } |
| } |
| [CreateNew] |
| public DomainsPresenter Presenter |
| { |
| get |
| { |
| return this._presenter; |
| } |
| set |
| { |
| if (value == null) |
| throw new ArgumentNullException("value"); |
| this._presenter = value; |
| thisthis._presenter.View = this; |
| } |
| } |
| #region IDefaultView Members |
| public void SetDataSource(List<ISentimentDomain> aDomains) |
| { |
| RadGrid1.DataSource = aDomains; |
| RadGrid1.DataBind(); |
| } |
| protected void RadGrid1_OnItemCommand(object source, GridCommandEventArgs e) |
| { |
| if ("Select" == e.CommandName) |
| { |
| GridDataItem row = e.Item as GridDataItem; |
| TableCell did = row["domain"]; |
| this._presenter.OnDomainSelected(did.Text); |
| } |
| } |
| protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) |
| { |
| if (e.Item is GridDataItem) |
| { |
| GridDataItem row = e.Item as GridDataItem; |
| TableCell dom = row["domain"]; |
| Image img = row["thumb"].FindControl("thumb") as Image; |
| img.ImageUrl = "~/img/delete.gif"; |
| this.RadToolTipManager1.TargetControls.Add(img.ClientID, dom.Text, true); |
| } |
| } |
| public void SetError(string sError) |
| { |
| Session["errormsg"] = sError; |
| Response.Redirect("~/Errors/WebAppError.aspx", true); |
| } |
| #endregion |
| } |
| } |
GridBoundColumn boundColumn = new GridBoundColumn();
view.Columns.Add(boundColumn);
boundColumn.DataField = "My.Custom.Object"; (note that Custom willbe null at some times, and therefore we cant sort the column).
The error occurs when I rebind the grid in Page_PreRender.
RadGrid1.DataSource = SomeDataSource;
try
{
RadGrid1.Rebind();
}
catch (Exception e)
{
// We will have a "Object reference not set to an instance of an object" error here...
}
Any way to get around this error?
Regards
Andreas Clausen
| <telerik:RadAjaxManager ID="ramManager" runat="server" DefaultLoadingPanelID="alpPan1" > |
| <AjaxSettings> |
| <telerik:AjaxSetting AjaxControlID="ramManager"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="lblCurDir" /> |
| <telerik:AjaxUpdatedControl ControlID="lblCurFile" /> |
| <telerik:AjaxUpdatedControl ControlID="imgPreview" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| </AjaxSettings> |
| </telerik:RadAjaxManager> |
| RadAjaxManager aM = RadAjaxManager.GetCurrent(Page); |
| if (aM == null) { |
| Response.Write("XFileExplorer needs an ajax manager in the page holding the control!"); |
| Response.End(); |
| return; |
| } |
| //calling ajax function changes grid and hidden fields - so add settings |
| aM.AjaxSettings.AddAjaxSetting(aM, hfCurDir); |
| aM.AjaxSettings.AddAjaxSetting(aM, hfCurFile); |
| aM.AjaxSettings.AddAjaxSetting(aM, rgBackupFiles); |
| aM.UpdatePanelsRenderMode = UpdatePanelRenderMode.Inline; |
| <telerik:RadAjaxManager ID="ramManager" runat="server" DefaultLoadingPanelID="alpPan1" > |
| <AjaxSettings> |
| <telerik:AjaxSetting AjaxControlID="ramManager"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="lblCurDir" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| <telerik:AjaxSetting AjaxControlID="ramManager"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="lblCurFile" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| <telerik:AjaxSetting AjaxControlID="ramManager"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="imgPreview" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| </AjaxSettings> |
| </telerik:RadAjaxManager> |
| AjaxSetting aS = new AjaxSetting(aM.ID); |
| string strLoadPanelID=aM.DefaultLoadingPanelID; //use default loading panel |
| aS.UpdatedControls.Add(new AjaxUpdatedControl(rgBackupFiles.ID, strLoadPanelID)); |
| aS.UpdatedControls.Add(new AjaxUpdatedControl(hfSaveCurDir.ID,strLoadPanelID)); |
| aS.UpdatedControls.Add(new AjaxUpdatedControl(hfSaveCurFile.ID,strLoadPanelID)); |
| aM.AjaxSettings.Add(aS); |
| aM.UpdatePanelsRenderMode = UpdatePanelRenderMode.Inline; |
| //calling ajax function changes grid and hidden fields - so add settings |
| AjaxSetting aS = new AjaxSetting(aM.ID); |
| string strLoadPanelID=aM.DefaultLoadingPanelID; //use default loading panel |
| //CANT DO THIS - WOULD REMOVE RENDER MODE aS.UpdatedControls.Add(new AjaxUpdatedControl(rgBackupFiles.ID, strLoadPanelID)); |
| aS.UpdatedControls.Add(new AjaxUpdatedControl(hfSaveCurDir.ID,strLoadPanelID)); |
| aS.UpdatedControls.Add(new AjaxUpdatedControl(hfSaveCurFile.ID,strLoadPanelID)); //add extra to preserver inline mode |
| aM.AjaxSettings.Add(aS); |
| aM.UpdatePanelsRenderMode = UpdatePanelRenderMode.Inline; |
| aM.AjaxSettings.AddAjaxSetting(aM, rgBackupFiles); |
In our application we have a Radgrid that contains several GridBoundColumns and a few GridCheckBoxColumns. Here is the code that defines 2 of them:
<telerik:GridBoundColumn
UniqueName="gbcWBSNumber"
DataField="WBSNumber"
HeaderStyle-HorizontalAlign="Center"
ItemStyle-HorizontalAlign="Center"
HeaderText="WBS #">
</telerik:GridBoundColumn>
<telerik:GridCheckBoxColumn
UniqueName="gccAllowBoes"
DataField="AllowBoes"
HeaderStyle-HorizontalAlign="Center"
ItemStyle-HorizontalAlign="Center"
HeaderText="Allow<br />BOEs">
</telerik:GridCheckBoxColumn>
We need a way to adjust the settings of these two objects using JavaScript. We are doing this successfully for the GridBoundColumn but not for the GridCheckBoxColumn.
In the following (greatly abbreviated) JavaScript we are able to obtain a reference to both objects(stored in the global variables WBSNumber and AllowBOEs respectively):
function WBSGridDoubleClick(sender, eventArgs)
{
(code removed…)
WBSNumber = MasterTableView.getCellByColumnUniqueName(MasterTableView.get_dataItems()[index], "gbcWBSNumber");
AllowBOES = MasterTableView.getCellByColumnUniqueName(MasterTableView.get_dataItems()[index], "gccAllowBOEs");
(code removed…)
}
After some other processing we acquire new values that we need to use to reset these two objects.
We have the following JavaScript code in our program to hopefully accomplish this:
function OnClientCloseWBSEast(oWnd)
{
// call a webservice to retrieve the modified data
WBSData.GetThisWBS(keyValues, OnGetThisWBSComplete);
}
// dt is actually an array of strings that contains the
// information we need
function OnGetThisWBSComplete(dt)
{
WBSNumber.innerText = dt[0]; // works fine!!!
AllowBOES.innertext = dt[4] // returns ‘true’ or ‘false’
}
Unfortunately, even though the value returned from the webservice in dt[4] reflects the latest change by the user, the ‘innerText’ property causes the checkbox to be removed and the value ‘true’ or ‘false’ to appear in the cell.
We have also tried innerHTML, value, and checked as properties for our CheckBox object but none of these work any better.
Can someone tell us what the proper syntax would be?
Thanks.