An optimal control problem when controls act on theboundary can also be understood as a variational principle under differentialconstraints and no restrictions on boundary and/or initial values. From thisperspective, some existence theorems can be proved when cost functionalsdepend on the gradient of the state. We treat the case of elliptic andnon-elliptic second order state laws only in the two-dimensionalsituation. Our results are based on deep facts aboutgradient Young measures.