JavaScript in ASP.NET
-
How to use the Javascript function in asp.net. THis is my sample code. <%@ Page Language="C#" AutoEventWireup="false" CodeFile="Default.aspx.cs" Inherits="_Default" %> function displayMessage() { alert("Hello world!"); } Untitled Page
Regards, A Jabeer Ali
-
How to use the Javascript function in asp.net. THis is my sample code. <%@ Page Language="C#" AutoEventWireup="false" CodeFile="Default.aspx.cs" Inherits="_Default" %> function displayMessage() { alert("Hello world!"); } Untitled Page
Regards, A Jabeer Ali
The OnClick method of your button needs to point to a method in your codebehind file. If you are using asp.net 2.0 you can set a onClientClick to your javascript method. If you are using asp.net 1.1 or 1.0 you need some code in the page load that takes the button control and does and Attribute.Add("OnClick","displayMessage"); Hope that helps. Ben
-
The OnClick method of your button needs to point to a method in your codebehind file. If you are using asp.net 2.0 you can set a onClientClick to your javascript method. If you are using asp.net 1.1 or 1.0 you need some code in the page load that takes the button control and does and Attribute.Add("OnClick","displayMessage"); Hope that helps. Ben
-
Thank u thats working fine. and do you have any solution for the onload event.
Regards, A Jabeer Ali
-
In the page load event If (!IsPostBack) { Button1.Attributes.Add("onClick","displayMessage"); } Ben
-
No No. I have done ur clientclick Event. Which is working fine. But i need the same type of event for the Page onload Event also. Would you help me.
Regards, A Jabeer Ali
-
If you want some javascript to run when the page loads you will have to set the onload event in the body tag in your html. Hope that helps. Ben