简体   繁体   中英

show html table on button click of asp.net server control

I am trying to display a table on the button click,right below the button,but it is getting display on the top of the page(Above the navbar). This is what I did:

Response.Write("<table border='1' cellpadding='2'  WIDTH='20%' height='10px' style=\"margin-bottom:10px\">");

what should be done to align the table below the button?please help

you should place a control and that add it into that control.
You can also take the help of html generic controls to add html control in the controls.

<asp:panel id="panel1" runat="server">
</panle>

and in code behind

panel1.InnerHtml="";

You should not be using Response.write. Either:

1) Use some JavaScript and HTML to show/hide the table.

2) Use server side control for example

ASPX page

<asp:panel runat="server" id="foo" visible="false">
<table border='1' cellpadding='2'  WIDTH='20%' height='10px' style=\"margin-bottom:10px\>
....
<asp:panel>

Code

foo.Visible = true;

See Show/Hide panels in ASP.net C# after submitting form

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