简体   繁体   English

在ASP.NET服务器控件的按钮单击上显示html表

[英]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. 您还可以利用html通用控件的帮助在控件中添加html控件。

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

and in code behind 并在后面的代码中

panel1.InnerHtml="";

You should not be using Response.write. 您不应该使用Response.write。 Either: 要么:

1) Use some JavaScript and HTML to show/hide the table. 1)使用一些JavaScript和HTML来显示/隐藏表格。

2) Use server side control for example 2)以服务器端控制为例

ASPX page ASPX页面

<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 提交表单后,请参阅ASP.net C#中的“显示/隐藏”面板

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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