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

By Rohatash Kumar 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" "">

<html xmlns="">

<head runat="server">


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

        function hideButton() {


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

            return false;




<div id="divAbc">

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




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

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





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


Rohatash Kumar

Normal 0 false false false EN-AU X-NONE X-NONE I am a Microsoft .NET software Developer and author and C# Corner MVP. I hold Masters degree i... Read more



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