no empty values

Jun 26, 2013 at 11:16 AM
Edited Jun 26, 2013 at 11:17 AM
Hello,

I'm trying to create a "Create AD User" script.
Is there any way to disallow empty fields?
Below is the code I'm working on, the task sounds simple enough, so I must be very noobish :-)
Function ShowUIWindow
{
$in = uniformgrid -ControlName "CreateADUser" -Columns 2 {
    "BrugerID" 
    textBox -Name "UserID"
    "Fornavn"
    textBox -Name "FirstName"
    "Efternavn"
    textBox -Name "LastName"
    "Password"
    textBox -Name "Password" Password123
    "Afdeling"
    ComboBox -IsEditable:$false -SelectedIndex 0 -Name Afdeling @("Administrationsafd","Driftafdelingen")
    
    
    button -Content "Cancel" -IsCancel -On_Click {
        Get-ParentControl | Close-Control
    }    
    new-button "Ok" -IsDefault -On_Click {
        $parent | Set-UIValue -passThru | Close-Control
        }
    
} -show
}
Regards
Thomas
Jun 26, 2013 at 3:44 PM
Edited Jun 26, 2013 at 3:45 PM
Helps to think a little, sorry guys easy solve
button "Ok" -IsDefault -On_Click {
        if (!$UserID.value){
        New-Label "Ikke alle felter er udfyldt" -show }
        else {
        Get-ParentControl | Set-UIValue -passThru | Close-Control
        } 
     }
Jun 26, 2013 at 4:03 PM
or so I thought.
it always evaluates to false it seems. I guess the value is not set at this point, so what to do?
Coordinator
Jun 26, 2013 at 10:21 PM
On a TextBox, the property you want is .Text not .Value