2011-12-07 23 views
2

我正在创建一个自定义Gridview控件,根据要求我必须在顶部寻呼机中放置两个图像按钮。在那里我能够显示图像按钮,但只有一个图像imagebutton显示图像另一个图像按钮没有。在asp.net中嵌入图像自定义控件

这里是代码:

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"); 
} 

我在assembly.info

[assembly: WebResource("myCustomGrid.Refresh.gif", "image/gif")] 
[assembly: WebResource("myCustomGird.PDF.gif", "image/gif")] 

我错在那里设置的属性生成操作两个图像嵌入资源

!任何帮助深表感谢。

回答

0

可能是一个错字。

您的意思是: -

[assembly: WebResource("myCustomGrid.PDF.gif", "image/gif")] 

,而不是...

[assembly: WebResource("myCustomGird.PDF.gif", "image/gif")] 
+0

是你指出的图像没有显示在imagebutton上。 – masif

+0

两者看起来都一样。 – masif

1

是否放置在项目的根这个图片吗?因为,如果不是,你必须添加相对路径。我不认为从asssembly路径。 你必须做出这样的:

[assembly: WebResource("{Your assembly full name}.{Path to image inside assembly and with replacement '/' to '.'}.{Image name}", "image/gif")] 

例如:

[assembly: WebResource("MyBestProject.Controls.resources.images.myCustomGird.PDF.gif", "image/gif")] 
+0

有两个图像'Refresh.gif'和'PDF.gif'在根文件夹中,refresh.gif图像显示正常但PDF.gif不是。 – masif

+0

跟着[link]( http://support.microsoft.com/kb/910442) – masif

+0

再次检查图像的路径和属性构建动作 – Baidaly

0

更新: 当imagebuttons渲染由Refresh.gif和PDF.gif imagebuttons respectively.The PDF.gif生成的HTML不加载,而不是我得到指定的备用文本是在这行代码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&amp;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&amp;t=634589418951556073" title="Export To PDF" name="ctl00$MainContent$customGrid0$ctl01$ctl01"> 
0

“仅” 2年后,我有一个SI类似问题。我只是通过查看这篇文章和我的问题之间的相似之处来解决我的一个简单的想法。也许别人会发现这个解决方案在未来有用。

问题出现在名称的ALLCAPS部分。出于某种原因,UpperLower的名字工作得很好,所有的更低。但我猜测ALLCAPS段在内部转换为其他内容,并且不起作用。在我的情况下,将我的图标从“ARROWLEFT.GIF”重命名为“ArrowLeft.gif”(文件名,注册以及对资源的任何引用)修复了此问题。

附加说明:我在同一个项目中创建了另一个图像,名为“icon_Calendar.GIF”,在我将其重命名为“icon_Calendar.gif”之前,该图像也无法正常工作。