Step1: Open a Sample Web Project and by default you have default.aspx
Step2:In the codebehind of default.aspx check the namespace having using System.Web.UI.If its not there,type the namespace in
the beginning of the code file.
Step3: Write the below line of code in Page_Load event or in any other event as per your requirements:
1.Page.RegisterClientScriptBlock("", "javascript function");-deprecated method in vs2008
RegisterClientScriptBlock method inserts the client-side script immediately below the opening tag of the Page object's
element. Form elements at this stage are not instantiated, so the code cannot access the form elements.
2.Page.RegisterStartupScript("", "javascript function");
RegisterStartupScript method inserts the specified client-side script just before the closing tag of the Page object's
element. Form elements at this stage are instantiated, so the code can access the form elements.
Note:javascript function: <script>alert("welcome to my web site")<script>
No comments:
Post a Comment