ASPX

2016-11-30 8 views
0

背後にあるコードから表示/非表示のdivは、私は次のようにボタンや進展に伴い、(ブートストラップ付)フォローHTMLページを持っている:ASPX

<%@ 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"); 
    } 

しかし、これは、私のために任意の提案を働いていませんか?

おかげ

答えて

0

は、あなたは、単にコード内のdivにrunat =「サーバー」とショーの非表示を行うことができます。

のC#で
<div id="divProgress" runat="server" 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> 

divProgress.Visible = false; 
+0

こんにちは、おかげでその仕事とボタンのコールバックにそれを示すがFinishWebRequestで、それは私のために働くイマイチ要求がbtnSend_Click' – Evyatar

+0

あなたは、要求は、あなたが任意のエラーを取得するか非同期 – Mairaj

+0

'で終わるとき – Evyatar

0

OnClientClickボタンハンドラに反応させることにより、クライアント側でのご使用のローディングインジケータが表示されるまでにどのような。

<asp:Button ID="btnSend" runat="server" OnClick="btnSend_Click" Text="Send" OnClientClick="onBeforeSend"/> 

結果を実行して戻った後、ページを更新すると、再び無効にすることができます。