我正在尝试在 aspx 中使用 jquery ui 主题(选项卡)。$(function () { $('#tabs').tabs(); });
<form id="form1" runat="server">
<div id="tabs">
<ul>
<li><a href="#tabs-1">tab 1</a></li>
<li><a href="#tabs-2">tab s2</a></li>
<li><a href="#tabs-3">tab 3</a></li>
</ul>
<div id="tabs-1">
tab-1
</div>
<div id="tabs-2">
tab-2
</div>
<div id="tabs-3">
Gridview is here
<asp:Button ID="Button2" runat="server" Height="31px" Text="Button"
onclick="Button2_Click" />
</div>
</div>
</form>
现在我正在调用函数 button2_click 在 Gridview 上执行一些操作,但我收到错误 Control 'GridView1' of type 'GridView' must be placed inside a form tag with runat=server
protected void Button2_Click(object sender, EventArgs e)
{
ExportToExcel(GridView1, "HElloWorld");
}
private void ExportToExcel(GridView gv, string filename)
{
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=" + filename + ".xls");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
gv.RenderControl(hw);
string style = @"<style> .textmode { mso-number-format:\@; } </style>";
Response.Write(style);
//Response.Write(GetMessage());
Response.Output.Write(sw.ToString());
// Response.Write(GetFooter());
Response.Flush();
Response.End();
}
gv.RenderControl(hw) 出现错误;