我收到一个错误-不包含消息的定义. [英] I am getting an error- does not contain a definition for message.

查看:71
本文介绍了我收到一个错误-不包含消息的定义.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,我在JavaScript中有一个功能-

Sir I have one function in JavaScript -

function message()
{
}



但是我遇到一个错误-"ASP.default_aspx"不包含"message"的定义,并且找不到扩展方法"message"接受类型为"ASP.default_aspx"的第一个参数(您是否缺少using指令或程序集引用?)"



But I am getting an error -"ASP.default_aspx'' does not contain a definition for ''message'' and no extension method ''message'' accepting a first argument of type ''ASP.default_aspx'' could be found (are you missing a using directive or an assembly reference?)" in

<div>
 <asp:Button ID="Button1" runat="server" onclick="message()" Text="Button"/>
</div>

推荐答案

您在OnClick事件中调用它
您需要在OnClientClick上调用它.
Your Calling it on OnClick event
you need to call that on OnClientClick.


正如mahen25所说,您需要在onclientclick事件中调用
As mahen25 said you need to call in onclientclick event
<asp:Button ID="Button1" runat="server" onclientclick="message()" Text="Button"/>


如果要调用函数服务器端,则需要在页面加载中注册Onclick事件.


You need to register the Onclick event in pageload if you want to call the function server side.

Button1.Attributes.Add("OnClick","message()");


这篇关于我收到一个错误-不包含消息的定义.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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