Embed client-side JavaScript in an ASP.NET 1.1 web page from server side code

来源:互联网 发布:物流配货软件 编辑:程序博客网 时间:2024/05/09 20:19

http://www.thescarms.com/dotnet/ClientJava.aspx

Many times on your web pages you may want to use client side JavaScript to perform validation or provide visual effects. JavaScript can be added to an ASP.NET page within the HTML code or it can be added in the server side code. To have the server side code render the JavaScript in the page, do not use the Response.Write method. Instead use the Pageclass.

The Page class offers the following methods:

Page.RegisterStartupScript
- adds JavaScript to the web form right before the ending </form> tag

Page.RegisterClientScriptBlock
- adds JavaScript to the web form, right after the <form runat="server"> declaration

Page.IsStartupScriptRegistered
- Determines if the client startup script is registered with the page

Page.IsClientScriptBlockRegistered
- Determines if the client script block is registered with the page

原创粉丝点击