如何在asp.net c#中创建具有两个不同操作的单个按钮? [英] how to create single button with two different operations in asp.net c#?

查看:56
本文介绍了如何在asp.net c#中创建具有两个不同操作的单个按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于前。如果我在音频流之后点击播放按钮,相同的按钮将变为暂停或停止。程序是什么?实际上我是c#asp.net的新手,正在开发媒体播放器应用程序。谢谢,抱歉我的英文不好

For ex. if i click the play button after audio streaming same button will change to pause or stop . what is the procedure? actually i''m newbie for c# asp.net im developing media player application. thanks & sorry for my bad english

推荐答案

protecred void btnPlay_Click(object sender, EventArgs e)
{
   btnPlay.Text = (btnPlay.Text == "Play") ? "Pause" : "Play";
}




单个按钮事件中如果你想执行多个条件你可以做什么做的是

根据你的例子你可以做的是,在Button事件中检查按钮的文本并相应地给予操作。



例如: -



Hi,
Within a Single Button Event If you want to Execute More than one condition what you can do is
According to your Example what you can do is, within the Button event check the text of the Button and Give the Operations Accordingly.

Eg:-

protected void BtnPlay_Click(object sender, ImageClickEventArgs e)
{
if(BtnPlay.Text=="Play")
{
//Your 1st Operation
BtnPlay.Text="Pause";
} else if(BtnPlay.Text=="Pause")
{
//Your 2nd Operation
BtnPlay.Text="Play";
}
}


这篇关于如何在asp.net c#中创建具有两个不同操作的单个按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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