Decrease Font Size
Increase Font Size
   BLOG

Creating Custom ASP.NET Server Controls with Embedded JavaScript and Style Sheet and Images

Creating Custom ASP.NET Server Controls with Embedded JavaScript and Style Sheet and Images

Embedding JavaScript in ASP.NET

Embedding Style Sheet in ASP.NET

Embedding Images in ASP.NET

 

Right click one of the images, select Properties, and change the Build Action value from Content to Embedded Resource. Repeat the same step for all the other images.

 Embed Images

Repeat the above step for the JavaScript and Style Sheet.

Double click the AssemblyInfo.cs. Add the following to the bottom of the file.

 
[assembly: System.Web.UI.WebResource("MyTextScroller.TextScroller.css", "text/css")]
[assembly: System.Web.UI.WebResource("MyTextScroller.TextScroller.js", "text/javascript")]
[assembly: System.Web.UI.WebResource("MyTextScroller.images.nav-arrow-down-hover.gif", "image/gif")]
[assembly: System.Web.UI.WebResource("MyTextScroller.images.nav-arrow-down.gif", "image/gif")]
[assembly: System.Web.UI.WebResource("MyTextScroller.images.nav-arrow-up-hover.gif", "image/gif")]
[assembly: System.Web.UI.WebResource("MyTextScroller.images.nav-arrow-up.gif", "image/gif")]

Note:

Default Namespace

The syntax - [assembly: System.Web.UI.WebResource("Default Namespace.File Location.File Name", "Type")]

Example 1

My Default Name Space is MyTextScroller

My JavaScript File name is TextScroller.js

And I’ll end up having this line in my AssemblyInfo.cs

[assembly: System.Web.UI.WebResource("MyTextScroller.TextScroller.js", "text/javascript")]

Example 2

My Default Name Space is MyTextScroller

My image is in images folder

My image name is nav-arrow-down-hover.gif

And I’ll end up having this line in my AssemblyInfo.cs

[assembly: System.Web.UI.WebResource("MyTextScroller.images.nav-arrow-down.gif", "image/gif")]

Comments (15) -

  • Stop Dreaming Start Action

    6/16/2009 8:25:08 PM |

    In fact the Difficult ASP.NET

  • Combi Boiler

    9/3/2009 11:31:20 PM |

    I have recently started to develop utilising Javascript in the client browser but  am realising it is a big learning curve.  The title " Creating Custom ASPNET Server Controls with Embedded JavaScript " in this post, right that made me interested. My previous experience is with php, mysql, most linux based tools and a little flash with actionscript. The challenges of utilising Javascript to produce a satisfactory client script which runs rapidly in all the established browsers, Internet Explorer, Safari, Firefox and Chrome seems a great head ache that is taking me numerous hours to master.  I find the tutorial web sites  are often strict and cover the identical points, discussion in web logs frequently reference actual methods to resolve problems that leads me through the learning curve more quickly. Interesting to read your thoughts and the comments in your web site on Javascript. Thanks for the article, it has helped in a moderate way to get me through the learning curve.

  • microsoft word how to

    1/2/2010 4:32:52 PM |

    Thanks for illustrating this, i may now try this to my computer. Smile

  • pid controller

    1/24/2010 1:43:14 PM |

    Starting to understand a bit more now... Thanks for keeping it simple!

  • live jasmin

    1/30/2010 6:10:46 PM |

    Have you ever considered adding more videos to your blog posts to keep the readers more entertained? I mean I just read through the entire article of yours and it was quite good but since I'm more of a visual learner,I found that to be more helpful.

  • javindo

    2/12/2010 11:51:50 PM |

    I wish I could download the example code...

  • Alpha Dog Training

    3/6/2010 5:24:18 PM |

    Hi, just surfing re web applic frameworks. Any two cents on silverlight? Kudos for meshing >Net, style sheets and javascript!

  • Interesting blog, not like the others!

    3/8/2010 6:44:00 PM |

    I love this blog

  • Best Free Sample

    3/18/2010 6:31:45 PM |

    The ideeas seen here are very nice...Wait for more...

  • Steve

    3/19/2010 6:02:37 PM |

    Interesting post Smile

  • Someone

    3/20/2010 6:04:55 AM |

    I love your blog

  • Dave

    4/1/2010 7:13:54 PM |

    thank you for the information, hopefully useful to others.
    greeting

  • Gia

    4/20/2010 4:49:37 AM |

    While i stumbled on this excellent site whilst looking in the internet. Really quite amazing, simply because search rankings can display quite aged answers yet somehow  is actually up-to-the-minute! Either way, wholly educational, especially because this is definitely not anything a lot of people will usually be able to write some thing good as regards to. Cya.

  • Nikki

    4/20/2010 6:54:21 AM |

    First of all let me thank you regarding this particular material it's not often you will find a post that's properly presented and informative I have been looking for information regardingthis info for a very lengthy period.

  • Mozoot

    1/16/2011 4:07:46 AM |


    Great post!!!, thanks

Add comment

Loading