I have an asp.net application which is a random generator and I want my button to disable and stay disabled when clicked.
I have tried adding OnClientClick="this.disabled = true;" to my <asp:button> and also tried adding the following to my onclick in the code behind
BtnDecideForMe.Attributes.Add("onclick", "this.disabled=true;"); but none of these work.
Not bothered how its done as long as it's clean and does the job.
HTML
<div class="col-sm-2">
<asp:Button class="btn btn-success" ID="BtnDecideForMe" runat="server" Text="Decide For Me" OnClick="BtnDecideForMe_Click" />
</div>
On_Click Event
protected void BtnDecideForMe_Click(object sender, EventArgs e)
{
List<string> Eat = new List<string>();
Eat.Add("Chinese Buffet");
Eat.Add("Harvester");
Eat.Add("Frankie & Benny's");
Eat.Add("Hungry Horse");
Eat.Add("Blaize");
Eat.Add("Chiquito");
Eat.Add("Cafe Football");
Eat.Add("Nando's");
Random Place = new Random();
int Places = Place.Next(0, Eat.Count);
txtDestination.Text = Eat[Places];
//BtnDecideForMe.Enabled = false;
}
I don't really want to use BtnDecideForMe.Enabled = false; as it loses my bootstrap styling and don't really want to apply a whole lot of css.