示例#1
0
        /// <summary>
        /// 尝试为文本控件设置一个值
        /// </summary>
        /// <param name="textInput">文本控件</param>
        /// <param name="value">要设置的值</param>
        /// <remarks>对于密码框此方法会设置失败并返回false</remarks>
        /// <returns>是否成功</returns>
        public static bool TrySetValue(this IHtmlTextControl textInput, string value)
        {
            textInput.TextValue = value;

            if (textInput.TextValue == value)
            {
                return(true);
            }

            return(false);
        }
示例#2
0
        /// <summary>
        /// 将客户端提交来的值,应用到对应的输入控件上
        /// </summary>
        /// <param name="control">输入控件</param>
        public static IHtmlTextControl ApplySubmittedValue(this IHtmlTextControl control)
        {
            if (control == null)
            {
                throw new ArgumentNullException("control");
            }

            var value = SubmittedValue(control);

            if (value == null)
            {
                return(control);
            }

            control.TextValue = value;

            return(control);
        }