Click here to Skip to main content
15,922,533 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Helo i am using external js file in visual studio for asp.net web application.I have a button in aspx design page.On button click i want to use alert function.here is the javascript i have used
<button type="button" önclick="alert('Welcome!')">Click Me!</button>

Here is the source code
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="Click me" />
please tell me to connect these two and also if i have to connect in future where should i add script in aspx page or in aspx.cs page?
Posted

in aspx.cs
C#
page_load(object sender,EventArgs)
{
  Button1.Attributes.Add("onClick","alert('button1 clicked');");
}
 
Share this answer
 
VB
<asp:Button ID="Button1" runat="server" onclientclick=
"javascript:alert('i am clicked')"
Text="Click me" />

must worked regards (:)
JavaScript

 
Share this answer
 
Sorry if i misunderstood you.. or failed to understand completely.. but i think you want to use external javascript to aspx page???

If it is so.. than you can add a reference to your js file in page header like mentioned below.



<script src="file location URL" type="text/javascript"></script>


Hope that will help
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900