事件"System.Web.UI.WebControls.Button.Click"只能出现在+ =或-=的左侧 [英] The event 'System.Web.UI.WebControls.Button.Click' can only appear on the left hand side of += or -=
本文介绍了事件"System.Web.UI.WebControls.Button.Click"只能出现在+ =或-=的左侧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨!我想在单击一个按钮时使一个按钮不可见.但是我收到此错误:``System.Web.UI.WebControls.Button.Click''事件只能出现在左侧的+ =或-= ...
这是我正在使用的代码.
Hi!I want to make invisible a button when one button is clicked.But I am getting this error:The event ''System.Web.UI.WebControls.Button.Click'' can only appear on the left hand side of += or -=...
This is the code I am using.
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
if (LoginButton.Click)
{
Buttonfill.Visible = false;
}
}
}
#endregion
private bool LoginButton_Click()
{
return true;
}
帮助解决此问题.请提供有效的代码.
Help fixing this.Give a valid code please.
推荐答案
您必须使用按钮的OnClick事件.
在aspxfile中,您可以在asp:Button声明中说:
OnClick ="Buttonfill_OnClick"
在文件后面的代码中
您创建一个名为:
的方法
You have to use the OnClick event of the button.
In the aspxfile you can say in the asp:Button declaration:
OnClick="Buttonfill_OnClick"
in the code behind file
you create a method called:
protected void Buttonfill_OnClick(object sender, EventArgs e)
{
Buttonfill.Visible = false;
}
您必须删除代码
you have to remove the code
if (LoginButton.Click)
{
Buttonfill.Visible = false;
}
通过您的Page_Load方法
from your Page_Load method
尝试一下:
Try this:
protected void Page_Load(object sender, EventArgs e)
{
LoginButton.Click += new System.Web.UI.LoginButtonClickEventHandler(LoginButton_Click);
}
protected void LoginButton_Click(object sender, EventArgs e)
{
Buttonfill.Visible = false;
}
希望对您有所帮助:)
hope it helps :)
这篇关于事件"System.Web.UI.WebControls.Button.Click"只能出现在+ =或-=的左侧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文