textbox and button
-
I know this is dumb question,but I am beginner in C# and do not have any book about it. I have a text box and a button,when user press this button I want to check if the text boxes are filled or not,and if the text is empty,change the text of button,I use this but it does not work:
private void Button1\_Click(object sender, System.EventArgs e) { if(TextBox1.Text==null) Button1.Text="Hello"; }
Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
Wish You Were Here-Pink Floyd-1975 -
I know this is dumb question,but I am beginner in C# and do not have any book about it. I have a text box and a button,when user press this button I want to check if the text boxes are filled or not,and if the text is empty,change the text of button,I use this but it does not work:
private void Button1\_Click(object sender, System.EventArgs e) { if(TextBox1.Text==null) Button1.Text="Hello"; }
Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
Wish You Were Here-Pink Floyd-1975try this one: private void Button1_Click(object sender, System.EventArgs e) { if(TextBox1.Text.Length == 0) Button1.Text = "Hello"; } or set the Enabled-Property of the Button to false at startup and override the TextChange Property of your TextBox maybe like this: private void TextBox1_TextChanged(object sender, System.EventArgs e) { if(this.TextBox1.Text.Length > 0) { this.Button1.Text = "Click me"; this.Button1.Enabled = true; } else { this.Button1.Text = "Hello"; this.Button1.Enabled = false; } } rgrds :)Martin
-
try this one: private void Button1_Click(object sender, System.EventArgs e) { if(TextBox1.Text.Length == 0) Button1.Text = "Hello"; } or set the Enabled-Property of the Button to false at startup and override the TextChange Property of your TextBox maybe like this: private void TextBox1_TextChanged(object sender, System.EventArgs e) { if(this.TextBox1.Text.Length > 0) { this.Button1.Text = "Click me"; this.Button1.Enabled = true; } else { this.Button1.Text = "Hello"; this.Button1.Enabled = false; } } rgrds :)Martin
-
try this one: private void Button1_Click(object sender, System.EventArgs e) { if(TextBox1.Text.Length == 0) Button1.Text = "Hello"; } or set the Enabled-Property of the Button to false at startup and override the TextChange Property of your TextBox maybe like this: private void TextBox1_TextChanged(object sender, System.EventArgs e) { if(this.TextBox1.Text.Length > 0) { this.Button1.Text = "Click me"; this.Button1.Enabled = true; } else { this.Button1.Text = "Hello"; this.Button1.Enabled = false; } } rgrds :)Martin
I think I made amistake about the place of my question,it's in a web form.My button does not enable when I add some text to text box??? Is there any difference between windows form and web application in this case? Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
Wish You Were Here-Pink Floyd-1975 -
I think I made amistake about the place of my question,it's in a web form.My button does not enable when I add some text to text box??? Is there any difference between windows form and web application in this case? Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
Wish You Were Here-Pink Floyd-1975I'm sorry, but I can't help you in this case. On my new Computer is only Win XP Home Edition installed. The Home Edition has no IIS, and without IIS i can't create Web-App's. I planed to Upgrade to Prof. Edition but the 'Update' isn't cheap !! So I hope that you can get help from another !! Rgrds Martin X|
-
I know this is dumb question,but I am beginner in C# and do not have any book about it. I have a text box and a button,when user press this button I want to check if the text boxes are filled or not,and if the text is empty,change the text of button,I use this but it does not work:
private void Button1\_Click(object sender, System.EventArgs e) { if(TextBox1.Text==null) Button1.Text="Hello"; }
Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
Wish You Were Here-Pink Floyd-1975 -
Assuming VS.NET wired up your event correctly try changing your code to this: if(TextBox1.Text == "") Button1.Text="Hello"; Andy Gaskell, MCSD MCDBA