连接javascript和asp.net [英] connecting javascript and asp.net
问题描述
Helo我在visual studio中使用外部js文件用于asp.net web应用程序。我在aspx设计页面中有一个按钮。在按钮上单击我想使用警报功能。这是我用过的javascript
< button type =buttonönclick=alert('Welcome!')>点击我!< / button>
这里是源代码
< asp:Button ID =Button1runat =serveronclick =Button1_Click
Text =Click me/>
请告诉我连接这两个,如果我以后必须连接,我应该在aspx页面或aspx.cs页面中添加脚本吗?
在aspx.cs中
page_load( object sender,EventArgs)
{
Button1.Attributes.Add( onClick, alert('button1 clicked'););
}
< asp:按钮ID = Button1 runat = server onclientclick =
javascript:alert('我被点击')
Text = 点击我 />
必须工作问候(:)
对不起,如果我误解了你..或未能完全理解..但我认为你想使用外部的JavaScript到aspx页面???
如果是这样..比你可以添加对你的js的引用页面标题中的文件如下所述。
< script src =file位置网址type =text / javascript>< / script>
希望有帮助
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?
in aspx.cs
page_load(object sender,EventArgs) { Button1.Attributes.Add("onClick","alert('button1 clicked');"); }
<asp:Button ID="Button1" runat="server" onclientclick= "javascript:alert('i am clicked')" Text="Click me" />
must worked regards (:)
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
这篇关于连接javascript和asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!