public
class RadGridExport : RadGrid
We are using the native PDF export features of the RadGrid control. I would like to be able to insert an image (corporate logo) into the beginning of the pdf file (above the data table data).
I found the OnPDFExporting() event and decided to override it and thus access the RawHTML stream.
I then attempted to add an image to the HTML via the <img> element:
protected override void OnPdfExporting(GridPdfExportingArgs e)
{
base.OnPdfExporting(e);
string newHTML = string.Empty;
string addHTML = string.Empty;
newHTML = e.RawHTML;
//THIS WORKS
addHTML =
@"<img alt='test' src='../images/corp_logo.gif'/>";
//THIS DOES NOT WORK (where URL is correct and resolvable)
addHTML =
@"<img alt='test' src='https://mycorp.net/pages/Custom/Images/corp_logo.gif'/>";
newHTML = addHTML + newHTML;
e.RawHTML = newHTML;
}
The issue that I am running into is that the above technique will work as long as I am using a relative path that resolves within the directory structure of the web application / virtual directory.
However, if I used an absolute path (via http:/ or file:/ or even embedded by data:) that I get an error similar to:
"System.SystemException: Error while creating area : Encountered web exception while fetching image from file:///C:/WORKING/MyProject/MyProject.Controls/Test/https://mycorp.net/pages/Custom/Images/corp_logo.gif: The given path's format is not supported."
Even though I have manually coded the src attribute with a absolute path to a URL... the RadGrid appears to resolve to my web apps directory structure.
Is there any way that I can avoid this behavior and have the src attribute work against an absolute?
Or is there another technique or method recommended for adding an image to a PDF file that is being exported?
Thanks,
M.T.
Update information. I'm using a usercontrol in DotNetNuke6. I've researched and it seems that its mostly an issue with the radAjaxManager. I'm still haveing problems with putting the manager on the parent page programmatically from the user control. I'm using
Dim manager As New RadAjaxManager()
manager.ID = "RadAjaxManager1"
Me.Page.Form.Controls.Add(manager)
But I don't think it is getting registered. If I can't get this last part to work I'm going to have to redo the entire structure.
As a hack work around a put a page refresh in the function OnClientClose
window.location.reload(true);
It's not very smooth but gets the job done for now. Is there a better way?
Added information: I'm moving this question over to the Ajax forum since it more of an issue with the RadAjaxManager than with the RadGrid. Sorry for the post but I did not see a way to delete.
Thanks
RadGrid1_ItemCommand then it does not show. I know that event is firing since I have a trace log file within the process.
If e.CommandName = RadGrid.InitInsertCommandName Then
e.Canceled = True
Dim newwindow As Telerik.Web.UI.RadWindow = New Telerik.Web.UI.RadWindow()
newwindow.ID = "RadWindow1"
newwindow.NavigateUrl = "/portals/0/NewEducation.aspx?RecID=0"
newwindow.OnClientClose = "OnClientClose"
newwindow.Width = New Unit(650)
newwindow.Height = New Unit(580)
newwindow.VisibleOnPageLoad = True
newwindow.Modal = True
RadWindowManager1.Windows.Clear()
RadWindowManager1.Controls.Add(newwindow)
End If
Please help. Thanks
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadGrid1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid1"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
"RadControls for ASP.NET AJAX requires a ScriptManager before any of the controls on the page. You may instead use the RadScriptManager although it is not required. RadScriptManager has some optimization capabilities that can be used for maximum performance."
I ran the first application from the Training Guide (PDF page 34), and I am getting the below error about the web.config file and using the SmartTag to configure this control as well as the RadScriptManager control:
'~/Telerik.Web.UI.WebResource.axd' is missing in web.config. RadScriptManager requires a HttpHandler registration in web.config. Please, use the control Smart Tag to add the handler automatically, or see the help for more information: Controls > RadScriptManager
Where does this control belong on the page and how do I fix the web.config so that this lesson can run in the browser correctly?
Thanks,
R2
<
telerik:RadComboBox
ID
=
"RadComboBox1"
runat
=
"server"
Width
=
"277px"
Height
=
"140px"
EmptyMessage
=
"Type in..."
DataTextField
=
"Item"
OnItemsRequested
=
"RadComboBox1_ItemsRequested"
AutoPostBack
=
"true"
EnableLoadOnDemand
=
"true"
Filter
=
"Contains"
LoadingMessage
=
"Loading..."
MarkFirstMatch
=
"true"
>
</
telerik:RadComboBox
>