简体   繁体   中英

Update panel with textbox values when button clicked

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!

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;

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...
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM