我有一个表格,其中显示了一些信息,但我想在点击上面的复选框后进行编辑。
class LoginForm extends React.Component {
state = {
identifier: '',
password: '',
errors: {},
isLoading: false
};
static contextTypes = {
router: PropTypes.object.isRequired
};
isValid = () => {
const { errors, isValid } = validateInput(this.state);
if (!isValid) {
this.setState({ errors });
}
return isValid;
};
onSubmit = (e) => {
e.preventDefault();
if (this.isValid()) {
this.setState({ errors: {}, isLoading: true });
const loginDetails = Object.assign({}, {identifier: this.state.identifier, password: this.state.password});
this.props.login(loginDetails).then(res => {
console.log('res', res);
return this.context.router.push('/');
}).catch(error => {
return this.setState(Object.assign({}, this.state, error, {isLoading: false}));
});
}
};
onChange = (e) => {
this.setState({ [e.target.name]: e.target.value });
};
render() {
const { errors, identifier, password, isLoading } = this.state;
return (
<form onSubmit={this.onSubmit}>
<fieldset>
<legend>Login</legend>
{ errors.form && <div className="alert alert-danger">{errors.form}</div> }
<TextFieldGroup
name="identifier"
label="Username / Email"
value={identifier}
error={errors.identifier}
onChange={this.onChange}
/>
<TextFieldGroup
name="password"
label="Password"
value={password}
error={errors.password}
onChange={this.onChange}
type="password"
/>
<div className="form-group">
<button className="btn btn-primary btn-lg" disabled={isLoading}>Login</button>
</div>
</fieldset>
</form>
);
}
}
export default connect(null, { login })(LoginForm);
这是一些HTML代码。我想添加一个函数,以便在单击复选框后可以编辑所有信息。 谢谢
答案 0 :(得分:0)
此处与C#或Linq无关(如您所标记)。
假设您正在使用ASP.NET应用程序
checkbox
检查更改事件时,启用textbox
。例如。文本编辑器的名称为txtRemarks
,复选框名称为chkRemarksEditor
on chkRemarksEditor检查更改事件: -
txtRemarks.Enabled = chkRemarksEditor.Checked;