Reputation: 4150
I am creating a custom Gridview control, according to requirement i have to place two image buttons in the Top Pager. where i am able to display imagebuttons in top pager but only one image imagebutton shows the image another imagebutton does not.
Here is code:
protected override void InitializePager(GridViewRow row,int columnSpan,PagedDataSource pagedDataSource)
{
//adding refresh button in TopPager
ImageButton Refresh = new ImageButton();
Refresh.ToolTip = "Refresh GridView";
Refresh.ImageAlign = ImageAlign.Right;
Refresh.AlternateText = "Refresh GridView";
ClientScriptManager cs1 = this.Page.ClientScript;
Refresh.ImageUrl = cs1.GetWebResourceUrl(typeof(myCustomGrid.CustomGrid), "myCustomGrid.Refresh.gif");
// adding button in TopPager to add new record..
ImageButton ExportToPDF = new ImageButton();
ExportToPDF.ToolTip = "Export To PDF";
ExportToPDF.AlternateText = "PDF Export";
ClientScriptManager cs2 = this.Page.ClientScript;
ExportToPDF.ImageUrl = cs2.GetWebResourceUrl(typeof(myCustomGrid.CustomGrid), "myCustomGrid.PDF.gif");
}
I have set both images properties build action to embedded resource
in assembly.info
[assembly: WebResource("myCustomGrid.Refresh.gif", "image/gif")]
[assembly: WebResource("myCustomGird.PDF.gif", "image/gif")]
where i am going wrong! any help is much appreciated.
Upvotes: 2
Views: 1021
Reputation: 1
"only" 2 years later, I had a similar issue. I just resolved mine with a simple idea that came by looking at the similarities between this post and my issue. Perhaps someone else will find this solution useful in the future.
The problem appears to be with the ALLCAPS section of the name. For some reason, UpperLower names work fine, as do all lower. But I am guessing ALLCAPS segments get converted to something else internally and don't work. In my case, renaming my icon from "ARROWLEFT.GIF" to "ArrowLeft.gif" (file name, registration, and any references to the resource) fixed the issue.
Additional Note: I had another image in the same project, named "icon_Calendar.GIF" which also wasn't working until I renamed it to "icon_Calendar.gif".
Upvotes: 0
Reputation: 4150
Update:
when the imagebuttons renders the HTML generated by Refresh.gif and PDF.gif imagebuttons respectively.The PDF.gif does not load instead i get the alternate text specified which is in this code line ExportToPDF.AlternateText = "PDF Export";
<input align="right" type="image" style="height:20px;width:20px;" alt="Refresh GridView" src="/WebResource.axd?d=CIOcfTt92OMP_aqepr-cGa2E4E8-uaiywsae5-4NcYocrJ-NE-cIL4Qb2JfX3tY0cIa8EwDzWnyeBqNiST34SNpBNuGjVC113XqMTprBN-XU9J7ilPsI6bsaXwHa-Qt30&t=634589418951556073" title="Refresh GridView" name="ctl00$MainContent$customGrid0$ctl01$ctl02">
<input type="image" style="height:20px;width:20px;margin-left:480px;" alt="PDF Export" src="/WebResource.axd?d=su3rsVMzKa7BNi4A-JZVUHPhHh3sS-oWW9bmAeK4I0h1A11NHqBD2setFyA3yundDC34YO0gbBoz5G0PHS0uxeQYI66QON_syQhIdlIKs4JzJW6H_oLErMjOZE6Q_slB0&t=634589418951556073" title="Export To PDF" name="ctl00$MainContent$customGrid0$ctl01$ctl01">
Upvotes: 0
Reputation: 1849
Does this images placed in root of the project? Because, if not you have to add relative path. And I don't see path from asssembly. You have to make like this:
[assembly: WebResource("{Your assembly full name}.{Path to image inside assembly and with replacement '/' to '.'}.{Image name}", "image/gif")]
For example:
[assembly: WebResource("MyBestProject.Controls.resources.images.myCustomGird.PDF.gif", "image/gif")]
Upvotes: 1
Reputation: 10680
Could be a typo.
Did you mean :-
[assembly: WebResource("myCustomGrid.PDF.gif", "image/gif")]
and not...
[assembly: WebResource("myCustomGird.PDF.gif", "image/gif")]
Upvotes: 0