Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
What are the ways to emit client-side JavaScript from server-side code in ASP.NET?
What are the ways to emit client-side JavaScript from server-side code in ASP.NET?
✍: Guest
The Page object in ASP.NET has two methods that allow emitting of client-side JavaScript:
RegisterClientScriptBlock and RegisterStartupScript. Example usage:
Page.RegisterClientScriptBlock("ScriptKey",
"<script language=javascript>" +
"function TestFn() {" +
" alert('Clients-side JavaScript'); }</script>");
Page.RegisterStartupScript("ScriptKey",
"<script language=javascript>" +
"function TestFn() {" +
" alert('Clients-side JavaScript'); }</script>");
ScriptKey is used to suppress the same JavaScript from being emitted more than once. Multiple calls to RegisterClientScriptBlock or RegisterStartupScript with the same value of ScriptKey emit the script only once, on the first call.
2010-10-05, 3393👍, 0💬
Popular Posts:
How To Create an Add-to-Netvibes Button on Your Website? - RSS FAQs - Adding Your Feeds to RSS News ...
How To Divide Query Output into Groups? - MySQL FAQs - SQL SELECT Query Statements with GROUP BY You...
The object that contains all the properties and methods for every ASP.NET page, that is built is .. ...
How To Create an Add-to-NewsGator Button on Your Website? - RSS FAQs - Adding Your Feeds to RSS News...
How To Retrieve the Count of Updated Rows? - Oracle DBA FAQ - Working with Database Objects in PL/SQ...