From the course: Complete Guide to PowerShell 7

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Handling user input

Handling user input

- [Instructor] Now, the next step in form building, not only putting the right controls on the page, that is to handle user interactivity. So, let's just take the code that we've got here. So we're creating the form, we're adding it to be in the center. We're putting a name and a text box, a submit, and then we have some logic. So, let's go and select the first half of it here and we'll just say Run Selection so that builds out our form. And in the interactivity, I want to change the syntax slightly, so let me just slide this over here. So you can see that what we're doing is we're adding a click to the button and then I'm checking if the name is null or has white space. And if it is, then I'm going to stop and say, can you "Please enter your name" as a message box. If it has a value, it will then render the name. So, let's just slide back this way. I'm going to add that interactivity or event to the object, and then click ShowDialog. And then from here, I can click Submit and it'll…

Contents