hi,
i want to write code on validation of text box , combo box
for make them not null fields,
And other for mae a text box only accept integer , one only accept string not integer value.
so pls. tell me where shud i write dis code & give me some examples of code
kool.net 0 Light Poster
Recommended Answers
Jump to PostTry something like this:
private void btnAdd_Click(object sender, EventArgs e) { //Must be an integer int scoreInput; if (string.IsNullOrEmpty(txtScore.Text) || !int.TryParse(txtScore.Text, out scoreInput)) { txtScore.Focus(); MessageBox.Show("Please enter a valid score", "Input Error"); txtScore.Focus(); //in case they double click the message and select another ctrl return; } else …
Jump to Posti am using windows application not web froms
Well in win forms you can do simple like this on button click:
if(textbox1.text=" ") { Messagebox.show("Please enter some value"); }
Similarly for combobox...........
Hope this help you..........:)
All 7 Replies
coder4Ever 0 Newbie Poster
sknake 1,622 Senior Poster Featured Poster
DdoubleD 315 Posting Shark
mikiurban 16 Junior Poster in Training
kool.net 0 Light Poster
avirag 10 Posting Whiz
avirag 10 Posting Whiz
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.