我正在C#.net中使用twitter引导在frontoffice中的Web应用程序。 在onClick按钮我需要显示一个包含progressBar div的div,并且当该过程完成时,隐藏div。我使用此代码:在C#中显示和隐藏div不起作用
web.aspx:
<asp:Button ID="btnProcess" runat="server" Text="Process" OnClick="btnProcess_Click" />
// on load web, this div is invisible
<div class="progress progress-striped active invisible" id="progressBar" runat="server">
<div class="bar" style="width: 90%;" id="percentProgresBar"></div>
</div>
而且我web.aspx.cs:
protected void btnProcess_Click(object sender, EventArgs e){
// here change class to "visible"
progressBar.Attributes["class"] = "progress progress-striped active visible";
//--- all my process ----
//--- all my process ----
//when my process finish, hide the div again, change the css class to "invisible"
progressBar.Attributes["class"] = "progress progress-striped active invisible";
}
我的问题是div是可见的,当我过程结束,而不是一开始。我该如何解决这个问题?为了使之前可见的分区---我的所有进程----并完成我的代码的一部分,使div再次不可见。
感谢您的帮助!
您将无法影响服务器端的元素,您必须使用客户端JavaScript来执行此操作并异步执行命令使用类似ajax的东西。 –