There are many scenarios it is recommended to use an embedded resource which is part of the assembly. One of the common cases is having a custom control with custom script file and wanting to ship them in a close assembly to other projects. Thanks to deployments reasons we prefer to ship only the assembly without the other resource files. There is a simple approach to do it in .Net 2.0.
Ok, what do we have to do in order to accomplish this task?
- We have a custom control which is called "AlertButton"(Inherit from the Button class).
- The control is complied into "MyCustomControls.dll" assembly.
2. Add a WebResource definition to the AssemblyInfo.
[assembly: System.Web.UI.WebResource([FileName], [ResourceType])]
3. Then register this web resource in your web control:
public class MyCustomControl : Button
protected override void OnInit(EventArgs e)
// For pages with ajax extension
("MyCustomControls.alertUtils.js", " MyCustomControls"));
// For pages without ajax extension
4. And that is all!
On my last project I had a mission to find an appropriate framework for exporting some images and text to a Pdf file format.
The basic guidelines that lead me were:
- This framework should be developed under the .Net framework.
- It must be an open source code and not just black box.
- The export to a Pdf process shouldn't affect the exported image quality.
- The framework will be easily to use.
After searching over the net I found the solution => The ITextSharp framework answers all my requirements.
ITextSharp is a .Net open source libraries that allows you to generate a Pdf file in run time. I added a basic example for working with this framework:
public static void ExportToPdfFile(string )
// step 1: creation of a document-object
Document document = new Document();
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a file
PdfWriter.getInstance(document, new FileStream("MyPdfFile.pdf", FileMode.Create));
// step 3: we open the document
Image jpeg = Image.getInstance(new Uri("http://itextsharp.sourceforge.net/examples/myKids.jpg"));
// step 4: we add the image to the document
// step 5: we close the document
Defiantly, it's a powerful framework that allows you to export almost everything to a Pdf file.