I am working on my project last year. Wherein:
I have a login and registration form on one page (WebForm):
When the user clicks on the anchor Register DropDown ddlType (hides) and TextBoxes - txtCustName , txtEmail and txtConfirmPassword (displays) on the client side Javascript:
function signupClick() { document.getElementById('divType').style.display = 'block' ? 'none' : 'block'; document.getElementById('<%=txtCustName.ClientID%>').style.display = 'inherit'; document.getElementById('<%=txtConfirmPassword.ClientID%>').style.display = 'inherit'; document.getElementById('<%=btnLogin.ClientID%>').style.display = 'none'; document.getElementById('<%=btnSignUp.ClientID%>').style.display = 'inherit'; document.getElementById('lblLogin').style.display = 'inherit'; document.getElementById('lblSignup').style.display = 'none'; }
Login form: -

And when the user clicks on the anchor DropDown Login ddlType (Displays) and Text Boxes - txtCustName , txtEmail and txtConfirmPassword ( txtConfirmPassword ) on the client side Javascript:
function loginClick() { document.getElementById('divType').style.display = 'none' ? 'block' : 'none'; document.getElementById('<%=txtCustName.ClientID%>').style.display = 'none'; document.getElementById('<%=txtConfirmPassword.ClientID%>').style.display = 'none'; document.getElementById('<%=btnLogin.ClientID%>').style.display = 'inherit'; document.getElementById('<%=btnSignUp.ClientID%>').style.display = 'none'; document.getElementById('lblLogin').style.display = 'none'; document.getElementById('lblSignup').style.display = 'inherit'; }
Registration form: -

Code of anchors and .aspx buttons:
<label id="lblSignup" style="float: right"> For new account? <a href="javascript:;" id="signup" onclick="signupClick()">Sign Up</a> </label> <label id="lblLogin" style="float: right; display: none"> For existing account? <a href="javascript:;" id="login" onclick="loginClick()">Login</a> </label> </div> <label style="width: 28%"> <asp:HyperLink ID="hlHome" NavigateUrl="Index.aspx" Text="Home" CssClass="btn btn-default" Width="100%" runat="server" /> </label> <label style="width: 70%; float: right"> <asp:Button ID="btnLogin" OnClick="btnLogin_Click" CssClass="btn btn-success" Width="100%" runat="server" Text="Login" /> <asp:Button ID="btnSignUp" OnClick="btnSignUp_Click" Style="display: none" Width="100%" CssClass="btn btn-primary" runat="server" Text="Sign Up" /> </label>
Question:
When the user clicks the Sign Up DropDown ddlType (Displays) and Text Boxes - txtCustName , txtEmail and txtConfirmPassword (Hides), but I want to prevent this condition, and the registration form should be shown:
private void ShowMessage(string msg) { ScriptManager.RegisterStartupScript(this, GetType(), null, "AutoHideAlert('" + msg + "');", true); } protected void btnSignUp_Click(object sender, EventArgs e) { string cusname = txtCustName.Text; string email = txtEmail.Text; string pass = txtPassword.Text; string confirm = txtConfirmPassword.Text; if (string.IsNullOrEmpty(cusname) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(pass) || string.IsNullOrEmpty(confirm)) { ShowMessage("Fill all cradentials of customer."); } else {
How can I stop it in the registration form?
Updated:
My problem is when you click on the โRegisterโ button, it sets up the โLoginโ form as such:
