Click here to Skip to main content
15,844,602 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good day Please i created a cbt application and have a start and a submit button.Whenever the start button is clicked it will take the user to the exam area then when the submit button is clicked the user get there result but i want the start button to be disabled permanently after the submit button has been clicked i dont want the same user to do the exam twice.Where Student dashboard is where the start button is.

What I have tried:

  public void submit_Click(object sender, EventArgs e)
        {
 StudentDashBoard db = new StudentDashBoard();
db.btnstart.Enabled = false;
Posted
Updated 19-Oct-17 0:41am
Comments
Karthik_Mahalingam 18-Oct-17 23:43pm    
is both the button in same form?
akinwunmi 19-Oct-17 18:41pm    
No different form
Karthik_Mahalingam 19-Oct-17 21:12pm    
Is both the form opened at same time ?
Ralf Meier 19-Oct-17 2:16am    
I suppose that you mean this even if the application is (re-)startet again ...?
akinwunmi 19-Oct-17 18:29pm    
yes thanks

1 solution

It seems that, on button click, you create a new instance of the form.
You don't have to (and should not).
Since when the event hanler is executed, the form is already instantiated, you just need to access the btntart instance in it:
C#
public void submit_Click(object sender, EventArgs e)
{
   btnstart.Enabled = false;
   // ...
}

Hope this helps. Kindly.
 
Share this answer
 
Comments
CPallini 19-Oct-17 5:58am    
5.
phil.o 19-Oct-17 6:26am    
Thanks :)
akinwunmi 19-Oct-17 18:57pm    
public void submit_Click(object sender, EventArgs e)
{
btnstart.Enabled = false;
// ...
}
this is not working i have tried if several times what i want is that the user will not be allowed to click the start button again if the user click on the submit button
phil.o 19-Oct-17 20:13pm    
If you want the start button to be disabled permanently (even if the application is restarted), then you will have to persist this state externally; either on the local filesystem, or on a server. But then, you will need a login system, unless your application is made for only one user.
Your requirements are not very clear, could you clarify them?
akinwunmi 22-Oct-17 3:24am    
the application is a cbt app where i can have multiple users.i dont want the user to take the exam twice so i have the start button when it time for the exam it will show then when the user click on it will take the user to the exam area once the user submit the question the start button should be disabled. so that that the user will not be able to take the exam twice.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900