Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/382.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 按钮未正常启动,在使用SubmitBehavior=”时启动;假;但是文本框的值是空的_Javascript_Asp.net - Fatal编程技术网

Javascript 按钮未正常启动,在使用SubmitBehavior=”时启动;假;但是文本框的值是空的

Javascript 按钮未正常启动,在使用SubmitBehavior=”时启动;假;但是文本框的值是空的,javascript,asp.net,Javascript,Asp.net,我正在使用ASP按钮,它在客户端正常工作,但在服务器端没有启动 <div style="text-align: center"> <div> <div id="UserName"> <b>LoginName</b> <asp:TextBox ID="txt_LoginName" runat="server"></asp:TextBox>

我正在使用ASP按钮,它在客户端正常工作,但在服务器端没有启动

<div style="text-align: center">
    <div>
        <div id="UserName">
            <b>LoginName</b>
            <asp:TextBox ID="txt_LoginName" runat="server"></asp:TextBox>
        </div>
    </div>
    <div>
         <div id="Password">
             <b>Password&nbsp;&nbsp;</b>
             <asp:TextBox ID="txt_Password" TextMode="Password" runat="server"></asp:TextBox>
         </div>
    </div>
    <div style="text-align: right; width: 210px;">
        <asp:Button ID="btn_SignIn" OnClientClick="LogInUser()" UseSubmitBehavior="false" runat="server" Text="Login`enter code here`" />
        <asp:Label ID="lbl_InValidError" runat="server"></asp:Label>
    </div>
</div> 

当我不使用时,服务器端不会触发事件。

将OnClient更改为:

OnClientClick="if (LogInUser() == false) return;"

这样,如果用户未经验证,它将阻止回发,但如果有效,它将允许回发继续。

我已经测试了您的代码,并且它对我的效果与预期一样。。。
Protected Sub btn_SignIn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_SignIn.Click
 If Trim(Me.txt_LoginName.Text) = "" Then
            lbl_InValidError.Text = "Please Enter Login Name."
            Return
        End If
        If txt_Password.Text = "" Then
            lbl_InValidError.Text = "Please Enter Password."
            Return
        End If
End Sub
OnClientClick="if (LogInUser() == false) return;"