Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    hide form after Submit

    just wanted to know how to hide the form (eg: registration form) once its submitted.
    i want that once the user enters the details in the form and submits just a message saying "Details added to be displayed" rather the form getting post back


    Thanx in advance

  • #2
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,065
    Thanks
    4
    Thanked 8 Times in 8 Posts
    enclose the form elements in a panel, in the click event set the visibility of the panel to false.

    example:
    Code:
    code behind:
    Sub next_Click(sender As Object, e As EventArgs)
        pnlform.visible = false
    End Sub
    
    
    html code:
    <form runat="server">
    <asp:panel id="pnlform" runat="server">
           UserName: <asp:TextBox id="UserName" runat="server" /><br />
           Password: <asp:TextBox id="Password" runat="server" TextMode="Password" /><br />
            <asp:Button id="next1" onclick="next_Click" runat="server" Text="Next" />
    </asp:panel>
    </form>

  • #3
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re : Thanx

    Thanx Miranda

  • #4
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up Re:

    It dint work


    This is my HTML Code

    <aspanel id="mypanel" runat="server">

    <form id=Form1 method=post runat="server">
    <asp:customvalidator id=CustomValidator1 style="Z-INDEX: 101; LEFT: 432px; POSITION: absolute; TOP: 232px" runat="server" ErrorMessage="User Already Exist" ControlToValidate="txtuser"></asp:customvalidator><asp:validationsummary id=ValidationSummary1 style="Z-INDEX: 102; LEFT: 168px; POSITION: absolute; TOP: 160px" runat="server" DisplayMode="List" ShowSummary="False" ShowMessageBox="True"></asp:validationsummary>
    <TABLE id=Table1 style="FONT-FAMILY: arial:font-size:11px" cellSpacing=0
    borderColorDark=white cellPadding=0 align=center borderColorLight=lightgrey
    border=1>
    <TR bgColor=lightgrey>
    <TH colSpan=2>R E G I S T R A T I O N</TH></TR>
    <TR>
    <TD><b>First Name</B></TD>
    <TD><asp:textbox id=txtfname runat="server"></asp:textbox><asp:requiredfieldvalidator id=RequiredFieldValidator1 runat="server" ErrorMessage="Enter First Name" ControlToValidate="txtfname">*</asp:requiredfieldvalidator></TD></TR>
    <TR>
    <TD><b>Last Name</B></TD>
    <TD><asp:textbox id=txtlname runat="server"></asp:textbox><asp:requiredfieldvalidator id=RequiredFieldValidator2 runat="server" ErrorMessage="Enter Last Name" ControlToValidate="txtlname">*</asp:requiredfieldvalidator></TD></TR>
    <TR>
    <TD style="HEIGHT: 17px"><b
    >Department</B></TD>
    <TD style="HEIGHT: 17px"><asp:dropdownlist id=drpdep runat="server"></asp:dropdownlist></TD></TR>
    <TR>
    <TD><b>User Name</B></TD>
    <TD><asp:textbox id=txtuser runat="server"></asp:textbox><asp:requiredfieldvalidator id=RequiredFieldValidator3 runat="server" ErrorMessage="Enter User Name" ControlToValidate="txtuser">*</asp:requiredfieldvalidator></TD></TR>
    <TR>
    <TD><b>Password</B></TD>
    <TD><asp:textbox id=txtpass runat="server" TextMode="Password"></asp:textbox><asp:requiredfieldvalidator id=RequiredFieldValidator4 runat="server" ErrorMessage="Enter Password" ControlToValidate="txtpass">*</asp:requiredfieldvalidator></TD></TR>
    <TR>
    <TD><b>Re-Enter Password</B></TD>
    <TD><asp:textbox id=txtpass1 runat="server" TextMode="Password"></asp:textbox><asp:comparevalidator id=CompareValidator1 runat="server" ErrorMessage="Passwords does not match" ControlToValidate="txtpass1" ControlToCompare="txtpass">*</asp:comparevalidator></TD></TR>
    <TR>
    <TD align=center colSpan=2><asp:button id=Button1 runat="server" Text="REGISTER"></asp:button></TD></TR></TABLE>
    </FORM>

    </asp:Panel>




    Code Behind is :


    private void Button1_Click(object sender, System.EventArgs e)
    {
    if(!Page.IsValid)
    return;
    mypanel.visible=false;
    string fname=txtfname.Text;
    string lname=txtlname.Text;
    string uid=txtuser.Text;
    string pass=txtpass.Text;
    string dept=drpdep.SelectedItem.Value.ToString();
    DateTime dt= DateTime.Today;
    string ddt=dt.ToString();

    string sqlin="insert into issueusers values('"+fname+"','"+lname+"','"+uid+"','"+pass+"',"+dept+",'"+ddt+"',0)";
    SqlCommand cmd=new SqlCommand(sqlin,myutility.connection.getinstance());
    cmd.ExecuteNonQuery();
    Response.Write("<center>User Added</center>");


    }


    Here i am using Singleton application for the connection. How do i use transaction in this code for insert

  • #5
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,065
    Thanks
    4
    Thanked 8 Times in 8 Posts
    Quote Originally Posted by sr_aneesh
    It dint work


    private void Button1_Click(object sender, System.EventArgs e)
    {
    if(!Page.IsValid)
    return;
    mypanel.visible=false;
    string fname=txtfname.Text;
    string lname=txtlname.Text;
    string uid=txtuser.Text;
    string pass=txtpass.Text;
    string dept=drpdep.SelectedItem.Value.ToString();
    DateTime dt= DateTime.Today;
    string ddt=dt.ToString();

    string sqlin="insert into issueusers values('"+fname+"','"+lname+"','"+uid+"','"+pass+"',"+dept+",'"+ddt+"',0)";
    SqlCommand cmd=new SqlCommand(sqlin,myutility.connection.getinstance());
    cmd.ExecuteNonQuery();
    Response.Write("<center>User Added</center>");


    }

    I see 2 things
    1st this line of code only runs if the page does not validate, correct?
    if(!Page.IsValid) instead of if(Page.IsValid)

    2nd your SQL Insert statement is missing the names of the fields to insert the values into
    string sqlin= "insert into issueusers values('"+fname+"','"+lname+"','"+uid+"','"+pass+"',"+dept+",'"+ddt+"',0)";
    instead of
    "insert into issueusers(fname,lname,uid,pass,dept,ddt,SomeOtherColumn) values('"+fname+"','"+lname+"','"+uid+"','"+pass+"',"+dept+",'"+ddt+"',0)";

  • #6
    New Coder
    Join Date
    Aug 2005
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Also, use a "placeholder" instead of a "panel". Placeholders are more ideal as containers to be made visible or not. Panels generate table tags, which depending on how you use them, can mess up page layouts in some browsers. Placeholders are much cleaner.
    Robert
    Gee! Web Tools
    Web Content Management / Internet Marketing modules including:
    Page Editor - Calendar Manager - News Editor - Contact Organizer - Mail Wizard

  • #7
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,065
    Thanks
    4
    Thanked 8 Times in 8 Posts
    Quote Originally Posted by rrhodes
    Panels generate table tags, which depending on how you use them, can mess up page layouts in some browsers. Placeholders are much cleaner.
    Panels generate a DIV tag not a table... The PlaceHolder Web server control does not have any visible output and is used as a place holder to add controls at run time.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •