ASP.NET Cafe
Tips and Tricks

ASP.NET: 3 Steps to embed web resources into dll

Monday, 24 December 2007 03:44 by Dmitriy

If you want to make your own custom control. Yes, custom - not user control. You have something that should work good, everywhere and run from single dll. But how to store images, javascript and other stuff inside this dll?  Everything looks fine, but it always cause problems. I decided to write 3 simple steps to embed javascript into your custom control.

  1. Add your JS file to custom control project. Right click on the file - Properties - Build Action - Embedded Resource
  2. Open your AssembyInfo.cs file and add following line

    [assembly: System.Web.UI.WebResource("YourNamespace.FileName.js", "application/x-javascript")]

  3. In your custom control OnLoad event add following line:

    Page.ClientScript.RegisterClientScriptResource(
    this.GetType(), "YourNamespace.FileName.js");

That's all!

Merry Christmas !!!

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   ASP.NET
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (2) | Comment RSSRSS comment feed

Related posts

Comments

April 14. 2008 01:50

pingback

Pingback from hector.newssiteworld.com

asp net programmer

hector.newssiteworld.com

July 26. 2008 21:21

pingback

Pingback from ab110.com

Always 英文技术文章参照( 十一 ){ UpdateTime:2008-7-27; } My article in the cnblogs - cnblogs.com

ab110.com

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

August 27. 2008 22:49