Click here to Skip to main content
15,887,027 members
Home / Discussions / C#
   

C#

 
AnswerRe: Converted VB.NET to C# With Error Pin
GREG_DORIANcod28-Nov-12 10:10
professionalGREG_DORIANcod28-Nov-12 10:10 
QuestionUrgent Help Pin
Asma AlShehhi27-Nov-12 10:27
Asma AlShehhi27-Nov-12 10:27 
AnswerRe: Urgent Help Pin
R. Giskard Reventlov27-Nov-12 12:19
R. Giskard Reventlov27-Nov-12 12:19 
AnswerRe: Urgent Help Pin
Eddy Vluggen27-Nov-12 12:55
professionalEddy Vluggen27-Nov-12 12:55 
GeneralRe: Urgent Help Pin
OriginalGriff27-Nov-12 21:08
mveOriginalGriff27-Nov-12 21:08 
AnswerRe: Urgent Help Pin
fjdiewornncalwe28-Nov-12 11:54
professionalfjdiewornncalwe28-Nov-12 11:54 
AnswerRe: Urgent Help Pin
BobJanova28-Nov-12 23:16
BobJanova28-Nov-12 23:16 
QuestionHow to prevent multiple button clicks Pin
MichCl27-Nov-12 10:15
MichCl27-Nov-12 10:15 
I have a c# .net project that has a button on the form. When the button is clicked twice, bad things happen. How do I disable the button?

I've tried disabling my button as follows but it doesn't work.
btn_Program.Enabled = false;


I've searched for this online, but every solution seems to reference asp.net. I don't think I have that, do I? I'm fairly new to c# and visual studio, so I may have it and not know it.

I liked the following discussion, but again, it refers to asp.net.
http://stackoverflow.com/questions/8473261/how-to-disable-a-button-after-1st-click[^]

The example I liked had the following code in it, but when I add it to my form class, it gets a compilation problem for ClientScript and Attributes:


C#
static void DisableButtonDuringPostback(Page page, Button control)
{
    StringBuilder sb = new StringBuilder();
    sb.Append("this.disabled = true;");
    sb.Append(page.ClientScript.GetPostBackEventReference(control, control.ID.ToString()));
    sb.Append(";");

    control.Attributes.Add("onclick", sb.ToString());

}


It said to add the following to Page_Load
DisableButtonDuringPostback(this.Page, Button3);


Compilation problems:
1. 'System.Windows.Forms.Button' does not contain a definition for id and no extension method id accepting a first argument of type 'System.Windows.Forms.Button' could be found (are you missing a using directive or an assembly reference?)

2. System.Windows.Forms.Button does not contain a definition for Attributes and no extension method Attributes accepting a first argument of type System.Windows.Forms.Button could be found (are you missing a using directive or an assembly reference?)

Any help would be very much appreciated.
AnswerRe: How to prevent multiple button clicks Pin
Eddy Vluggen27-Nov-12 12:48
professionalEddy Vluggen27-Nov-12 12:48 
GeneralRe: How to prevent multiple button clicks Pin
MichCl28-Nov-12 8:31
MichCl28-Nov-12 8:31 
AnswerRe: How to prevent multiple button clicks Pin
lukeer27-Nov-12 20:17
lukeer27-Nov-12 20:17 
GeneralRe: How to prevent multiple button clicks Pin
MichCl28-Nov-12 7:40
MichCl28-Nov-12 7:40 
GeneralRe: How to prevent multiple button clicks Pin
MichCl28-Nov-12 7:41
MichCl28-Nov-12 7:41 
QuestionTop books for learning C# (Complete novice) for thermodynamic mathematical modelling Pin
Mahdi Kapateh27-Nov-12 8:05
Mahdi Kapateh27-Nov-12 8:05 
AnswerRe: Top books for learning C# (Complete novice) for thermodynamic mathematical modelling Pin
Richard MacCutchan27-Nov-12 9:53
mveRichard MacCutchan27-Nov-12 9:53 
AnswerRe: Top books for learning C# (Complete novice) for thermodynamic mathematical modelling Pin
Nelek27-Nov-12 12:37
protectorNelek27-Nov-12 12:37 
GeneralRe: Top books for learning C# (Complete novice) for thermodynamic mathematical modelling Pin
Richard MacCutchan27-Nov-12 23:47
mveRichard MacCutchan27-Nov-12 23:47 
GeneralRe: Top books for learning C# (Complete novice) for thermodynamic mathematical modelling Pin
Nelek28-Nov-12 11:47
protectorNelek28-Nov-12 11:47 
AnswerRe: Top books for learning C# (Complete novice) for thermodynamic mathematical modelling Pin
Matt T Heffron27-Nov-12 12:59
professionalMatt T Heffron27-Nov-12 12:59 
GeneralRe: Top books for learning C# (Complete novice) for thermodynamic mathematical modelling Pin
Mahdi Kapateh28-Nov-12 3:04
Mahdi Kapateh28-Nov-12 3:04 
QuestionDynamically loading a plug-in assembly by interface Pin
MJL Rademakers27-Nov-12 4:07
MJL Rademakers27-Nov-12 4:07 
AnswerRe: Dynamically loading a plug-in assembly by interface Pin
Alan N27-Nov-12 4:27
Alan N27-Nov-12 4:27 
GeneralRe: Dynamically loading a plug-in assembly by interface Pin
MJL Rademakers27-Nov-12 4:41
MJL Rademakers27-Nov-12 4:41 
AnswerRe: Dynamically loading a plug-in assembly by interface Pin
Pete O'Hanlon27-Nov-12 4:30
mvePete O'Hanlon27-Nov-12 4:30 
GeneralRe: Dynamically loading a plug-in assembly by interface Pin
MJL Rademakers27-Nov-12 4:45
MJL Rademakers27-Nov-12 4:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.