Click here to Skip to main content
12,625,607 members (34,044 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

9.4K views
Posted

Embedding Javascript in Asp.Net

, 5 Jul 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
This is going to do something much more interesting than merely render some HTML to the browser. This is going to inject Javascript and CSS into its containing page.
There is one main class in the ASP.NET Framework included for working with Javascript: the ClientScriptManager class. This class is exposed by the Page.ClientScript property. The ClientScriptManager class has several useful methods for working with Javascript including:


RegisterClientScriptBlock():
Adds a script to a page right after the opening server-side <form> tag

RegisterStartupScript():
Adds a script to a page right before the closing server-side <form> tag

RegisterClientScriptInclude():
Adds a reference to an external Javascript file
GetWebResourceUrl() - Returns the URL to a server-side resource

for more info: Building a Custom ASP.NET Control that uses Javascript, Cascading Style Sheets, and Ajax[^]

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Sunasara Imdadhusen
Software Developer (Senior) Infostretch Ahmedabad-Gujarat
India India
Aspiring for a challenging carrier wherein I can learn, grow, expand and share my existing knowledge in meaningful and coherent way.

sunaSaRa Imdadhusen

AWARDS:
  1. 2nd Best Mobile Article of January 2015
  2. 3rd Best Web Dev Article of May 2014
  3. 2nd Best Asp.Net article of MAY 2011
  4. 1st Best Asp.Net article of SEP 2010

Read More Articles...

You may also be interested in...

Pro

Comments and Discussions

 
General[My vote of 1] Not Clear at all Pin
Alireza_136228-Mar-13 21:05
memberAlireza_136228-Mar-13 21:05 
GeneralRe: [My vote of 1] Not Clear at all Pin
Sunasara Imdadhusen22-Apr-14 4:57
professionalSunasara Imdadhusen22-Apr-14 4:57 
GeneralReason for my vote of 2 This is too common and obvious to qu... Pin
Misha19645-Jul-11 13:39
memberMisha19645-Jul-11 13:39 
GeneralRe: Reason for my vote of 2This is too common and obvious to qu... Pin
Sunasara Imdadhusen22-Apr-14 4:58
professionalSunasara Imdadhusen22-Apr-14 4:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161205.1 | Last Updated 5 Jul 2011
Article Copyright 2011 by Sunasara Imdadhusen
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid