0

I am still learning the basics of C# so any help would be appreciated. I have a series of asp:TextBox's. In the code behind, I am getting the value of these boxes. Is there a way to have a panel hidden until a user clicks submit then have the values display?

Here is the HTML for one of the boxes and the panel:

<asp:TextBox ID="txtTitle" runat="server></asp:TextBox>

<asp:Panel ID="PDFPanel" runat="server"></asp:Panel>

The button:

<asp:Button ID="btn_Submit" runat="server" Text="Button" OnClick="btnSubmit"/>

and the code-behind for it:

string Title = txtTitle.Text;

 public void btnSubmit(Object sender, EventArgs e)
    {

    }

There are about 50 fields, so I am not showing all of it but if I can get direction on one I can replicate for the rest. Please let me know if I need to show any additional code

I am sorry if this is simple, but like I said, I am still an entry level developer. Thanks in advance!

2 Answers 2

2

Unless I've misunderstood what you're asking, this should be fairly simple.

<asp:Panel ID="PDFPanel" runat="server" Visible="False">
   <div>
       <asp:Literal id="litTitle" runat="server" />
   </div>
</asp:Panel>

then in your click method:

litTitle.Text = txtTitle.Text;
PDFPanel.Visible = true;
1
  • 1
    Nope, you understand correctly. This is a simple task that I was confused on how to properly syntax.
    – Peter
    Feb 4, 2014 at 1:11
2

Set the Panel's visibility to false by default

<asp:Panel ID="PDFPanel" runat="server" Visible="false">
    <asp:TextBox ID="txtTitle" runat="server"></asp:TextBox>
</asp:Panel>

then on the Button's click event set the visibility to true

public void btnSubmit(Object sender, EventArgs e)
{
    PDFPanel.Visible = true;
    // do something else...
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.