Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. public class Validation
  2. {
  3. public static bool textFieldInteTomt(TextBox field, string label)
  4. {
  5. if (field.Text == "")
  6. {
  7. MessageBox.Show(label + " måste fyllas i. Vänligen ange ett värde.");
  8. field.Focus();
  9. return false;
  10. }
  11. else
  12. {
  13. return true;
  14. }
  15. }
  16.  
  17. public static bool kollaUrl(string url)
  18. {
  19. try
  20. {
  21. var xml = "";
  22. using (var client = new System.Net.WebClient())
  23. {
  24. client.Encoding = Encoding.UTF8;
  25. xml = client.DownloadString(url);
  26. return true;
  27. }
  28. }
  29. catch (Exception)
  30. {
  31. MessageBox.Show("Vänligen ange en korrekt url.");
  32. return false;
  33. }
  34. }
  35.  
  36.  
  37.  
  38.  
  39. public static bool comboBoxInteTomt(ComboBox combo, string label)
  40. {
  41. if (combo.Text == "")
  42. {
  43. MessageBox.Show(label + " är inte valt, vänligen ange ett " + label);
  44. combo.Focus();
  45. return false;
  46. }
  47. else
  48. {
  49. return true;
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement