How to call a JavaScript function on ASP.NET page load Using VB.NET

By Rohatash Kumar Blogs | Visual Basic 2010 Aug 01, 2011
This blog defines how to call a JavaScript function on ASP.NET.

This blog defines how to call a JavaScript function on ASP.NET.

ASPX code

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication11.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title></title>

    <script language="javascript" type="text/javascript">

        function hideButton() {

 

            document.getElementById("divAbc").style.visibility = "hidden";

            return false;

        }

       

</script>

<div id="divAbc">

<table><tr><td style="width: 200px; height: 100px; background-color: red"></td></tr></table>

</div>

</head>

<body>

<form id="form1" runat="server">  

<asp:Button ID="btnHide" Runat="server" Text="Hide"  />&nbsp;

</div>

    </form>

</body>

</html>

Now double click on the form and the following code page load event.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        btnHide.Attributes.Add("onclick", "return hideButton()")

    End Sub

 

COMMENT USING

PREMIUM SPONSORS

Hire Mobile & Web Developer on demand. 100% satisfaction. Try for 1 week or Money Back. Local and remote developers available all over USA.

Latest Blogs