A first-order necessary condition for an infinite-dimensional nonlinear op-timization problem, which arises when the all-at-once method is employed to slove theoptimal control problems, is formulated and analyzed. Operator constraint and simplebound on part of the variables are both considered. Based on this optimality condition,the trust-region subproblems are built, then the trust region method rnay be employedto deal with the optimizatiou problem in infinite-dimensional space.