用VS2008编写校验用户名是否存在

 先拖动AJAX面板中的ScriptManager 再拖UpdatePanel到设计界面中.

代码类似

                            <asp:ScriptManager ID="ScriptManager1" runat="server">

 先拖动AJAX面板中的ScriptManager 再拖UpdatePanel到设计界面中.

代码类似

                            <asp:ScriptManager ID="ScriptManager1" runat="server">
                            </asp:ScriptManager>
                            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                <ContentTemplate>
                                    <asp:Button ID="myCheckUser" runat="server" CausesValidation="False"
                                         Text="检测" onclick="myCheckUser_Click" />
                                    <asp:Label ID="userLabel" runat="server"></asp:Label>
                                </ContentTemplate>
                            </asp:UpdatePanel>

再到cs文件写函数即可。

                string ReStr = Convert.ToString(cmd3.Parameters["@OptDescription"].Value);
                if (ReStr == "noUser")
                {
                    userLabel.Text = "恭喜,可以使用";
                }
                else
                {
                    userLabel.Text = "用户名不可用";
                }

发表评论

电子邮件地址不会被公开。 必填项已用*标注