【发布时间】:2016-11-30 19:38:33
【问题描述】:
我有以下 html 页面(带引导程序),按钮和进度如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="TestLoading.WebForm1" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<link href="/css/bootstrap.min.css" rel="stylesheet" />
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btnSend" runat="server" OnClick="btnSend_Click" Text="Send" Width="71px" CssClass="btn btn-info" style="display: inline"/>
<div class="progress" runat="server" id="loadingSend">
<div class="progress-bar progress-bar-info progress-bar-striped active" aria-valuemax="100" aria-valuemin="0" aria-valuenow="100" role="progressbar" style="display: none">
Loading...
</div>
</div>
</div>
</form>
我想在后面的代码中显示/隐藏进度条,我尝试了什么:
private HttpWebRequest request;
protected void btnSend_Click(object sender, EventArgs e)
{
request = (HttpWebRequest)WebRequest.Create("http://localhost:65533/MyService.svc/");
request.Method = WebRequestMethods.Http.Get;
request.ContentType = "application/json";
HtmlControl control = FindControl("loadingSend") as HtmlControl;
control.Style.Add("display", "block");
request.BeginGetResponse(new AsyncCallback(FinishWebRequest), null);
}
void FinishWebRequest(IAsyncResult result)
{
StringBuilder sb = new StringBuilder();
request.EndGetResponse(result);
var response = (HttpWebResponse)request.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
HtmlControl control = FindControl("loadingSend") as HtmlControl;
control.Style.Add("display", "none");
}
但这对我不起作用,有什么建议吗?
谢谢
【问题讨论】:
标签: javascript html css asp.net