我正在尝试创建一个登录页面。每当我点击登录按钮用户名时,文本框的文字就会变空。
我试过了:
继承人:markUp:
<label for="username">Username</label>
<%--<input type="text" name="Uname" id="username"/>--%>
<asp:TextBox ID="txtusrnm" runat="server" AutoPostBack="true"/>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" name="Pname" id="password">
</div>
<div class="form-group"><a href="#">Forgot password?</a></div>
<hr class="hr-sm hr-stroke" />
<div class="form-group">
<%--<input id="btnlogin" type="button" class="btn btn-primary btn-wide" value="Login" runat="server" onserverclick="btnlogin_ServerClick" >--%>
<asp:Button ID="btnLogin" runat="server" Text="Login" class="btn btn-primary btn-wide" OnClick="btnLogin_Click" UseSubmitBehavior="false" EnableViewState="true" />
答案 0 :(得分:1)
我可以解决我的问题,我在文本框中有AutoPostBack='true'
所以只是删除了UseSubmitBehavior="false" EnableViewState="true"
并将CausesValidation="False"
替换为<asp:TextBox ID="txtusrnm" runat="server"/>
,现在运行正常。
文本框:
<asp:Button ID="btnLogin" runat="server" Text="Login" class="btn btn-primary btn-wide" OnClick="btnLogin_Click" CausesValidation="False"/>
和按钮:
var films = [
{
movie: "fast and the furious",
rating: 4,
seen: true
},
{
movie:"13 reasons why",
rating: 5,
seen: true
},
{
movie:"beaty and the beast",
rating: 4,
seen: false
}
];
films.forEach(function(film){
var result = "You have ";
if(film.seen) {
result += "watched ";
}
else{
result += "not seen ";
}
result += "\"" + film.movie + "\" - ";
result += film.rating + " stars";
console.log(result);
});
由于