2010-03-25 46 views
0

在頁面加載一個面板不能被看到,onclick按鈕一些進程將繼續,那時我需要以某種表示法顯示進程,一旦進程結束,我需要顯示面板ajax控件在給定場景中的使用

請幫幫我。

+0

您能詳細說明您的意思嗎?「我需要顯示該過程是一些符號」? – 2010-03-25 14:11:36

回答

0

你有幾個選項。一種是通過設置面板的內容Document.getElementById("panel_id").innerHTML = "Your content here..."

另一種方法是使用CSS元素在加載時隱藏面板。然後在onclick代碼中更改該面板的屬性。有關詳細信息:http://www.w3schools.com/CSS/pr_class_visibility.asp

0

如果您正在使用AJAX,你有兩個主要選擇:

  1. 裹在ASP.NET UpdatePanel控件的控制和處理的代碼隱藏面板知名度。
  2. 使用javascript(推薦使用jQuery)在後臺代碼中向WebMethods發出ajax請求,並在請求成功時從客戶端更新UI。

如果您是ASP.NET/AJAX的新手,我會推薦選項1,因爲它更容易實現。要做到這一點,你就會有這樣的事情:

標記:

<asp:ScriptManager ID="ScriptManager1" runat="server"/> 
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
    <ContentTemplate> 
     <asp:Panel ID="MyPanel" runat="server" Visible="false"> 
      <!-- panel contents here --> 
     </asp:Panel> 
     <asp:Button ID="MyButton" runat="server" OnClick="MyButton_Click" Text="Do Something"/> 
    </ContentTemplate> 
</asp:UpdatePanel> 

代碼隱藏:

protected void MyButton_Click(object sender, EventArgs e) 
{ 
    //do something when the button is clicked 

    //set the panel visible so that when this round trip is complete, the panel will show 
    MyPanel.Visible = true; 
} 

以上會使用AJAX來處理按鈕單擊事件,你可以這樣做無論您需要什麼,然後將面板設置爲可見。