我该如何在ASP按钮单击事件上调用用JavaScript编写的函数. [英] How can i call function written in javascript on asp button click event.

查看:102
本文介绍了我该如何在ASP按钮单击事件上调用用JavaScript编写的函数.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在使用Visual Studio2005.
我想使用外部javascript.

我的代码可以正常使用widout主页.
但是如果我使用母版页而不是它的nt工作.

谁能帮我吗?


DEFAULT.ASPX

Hi,
Im using visual studio 2005.
I want to use external javascript.

MY code is working proper widout master page.
But if i use master page than it''s nt working.

Can anyone help me?


DEFAULT.ASPX

<%@ Page Language="VB" MasterPageFile="~/Master page/MasterPage.master" AutoEventWireup="false" CodeFile="A.aspx.vb" Inherits="A" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    
    <script type="text/javascript" src="JScript.js" language="javascript"></script>
    <form id="form1" runat="server">
    <div>
         <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button2" runat="server" Text="Button" OnClientClick="return checkUser();"/><br />
       </div>
    </form>
</asp:Content>


==========================================
jSCRIPT.JS


=============================================
jSCRIPT.JS

function checkUser()
{
    if(form1.TextBox1.value=="xyz")
    {
        alert("Please enter appropriate value..");
        return false;
    }
    return true;
}

推荐答案

我认为,链接到外部JavaScript的行应移至母版页的HEAD部分.那是这行;
I think that the line that links to the external JavaScript should be moved to the HEAD section of the masterpage. That''s this line;
<script type="text/javascript" src="JScript.js" language="javascript"></script>


如果der只是函数中的警报消息,但是当我添加if(form1.TextBox1.value =="xyz")时,它将调用函数单击事件未调用d函数.我不明白它背后的原因是什么.
It call function if der is only alert message in function but when i add the if(form1.TextBox1.value=="xyz") click event not calling d function. I can''t understand what is d reason behind it.


如果der只是函数中的警报消息,但是当我添加if(form1.TextBox1.value ==时,它将调用函数"xyz")click事件未调用d函数.我不明白它背后的d原因是什么."

der在德语中只是一个字. d是字母而不是单词.别像智障人士那样说话,您面前有完整的键盘.

如果您的控件在客户端上甚至调用了TextBox1?您需要使用ClientID属性,而不是您在服务器上提供的名称.


"It call function if der is only alert message in function but when i add the if(form1.TextBox1.value=="xyz") click event not calling d function. I can''t understand what is d reason behind it."

der is only a word in German. d is a letter not a word. Don''t talk like a retard, you have a full keyboard in front of you.

If your control even called TextBox1 on the client ? You need to use the ClientID property, not the name you give on the server.


manishathakkar写道:
manishathakkar wrote:

widout



您不知道这会使您看起来多么无知.这是一个专业网站,不是12岁男孩的聚会场所.



You have no idea how ignorant this makes you look. This is a professional site, not a hangout for 12 year old boys.


这篇关于我该如何在ASP按钮单击事件上调用用JavaScript编写的函数.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆