请等待加载消息

时间:2012-02-17 03:50:07

标签: asp.net vb.net

页面的屏幕截图

enter image description here

ASPX代码

<div style="width:729px;background:white;">
<div id="tabs">
<div><asp:LinkButton ID="LinkButtonDefinitions" runat="server">Definitions</asp:LinkButton></div>
<div><asp:LinkButton ID="LinkButtonEmployees" runat="server">Employees</asp:LinkButton></div>
<div><asp:LinkButton ID="LinkButtonFamily" runat="server">Family</asp:LinkButton></div>
<div><asp:LinkButton ID="LinkButtonHomeTown" runat="server">Home Town</asp:LinkButton></div>
<div><asp:LinkButton ID="LinkButtonOtherThanHomeTown" runat="server">Other Than Home Town</asp:LinkButton></div>
<div><asp:LinkButton ID="LinkButtonAdmissibility" runat="server">Admissibility</asp:LinkButton></div>
<div><asp:LinkButton ID="LinkButtonTypesOfLTC" runat="server">Types Of LTC</asp:LinkButton></div>
<div><asp:LinkButton ID="LinkButtonBlockPeriod" runat="server">Block Period</asp:LinkButton></div>
<div><asp:LinkButton ID="LinkButtonEntitlement" runat="server">Entitlement</asp:LinkButton></div>
<div><asp:LinkButton ID="LinkButtonAdvance" runat="server">Advance</asp:LinkButton></div>
<div><asp:LinkButton ID="LinkButtonAdjustmentofadvance" runat="server">Adjustment of advance</asp:LinkButton></div>
<div><asp:LinkButton ID="LinkButtonReimbursement" runat="server">Reimbursement</asp:LinkButton></div>
<div><asp:LinkButton ID="LinkButtonCarryOverForfeitureofclaim" runat="server">Carry Over & Forfeiture of claim</asp:LinkButton></div>
<div><asp:LinkButton ID="LinkButton1RelaxationsInterpretations" runat="server">Relaxations & Interpretations</asp:LinkButton></div>
</div>
</div>

代码背后

Public Sub loadContent(ByVal PageName As String)
  Dim _con As New SqlConnection(ConfigurationManager.ConnectionStrings("LeaveDBConnectionString").ConnectionString)
  Dim _da As New SqlDataAdapter("SELECT PageHeader,PageContent FROM PageKeeper WHERE PageName='" & PageName & "'", _con)
  Dim _table As New DataTable

  Try
    _con.Open()
    _da.Fill(_table)
    _con.Close()
    _con.Dispose()
    With _table.Rows(0)
      h4header.InnerText = .Item(0)
      divUpdatePanel.InnerHtml = .Item(1)
      Me.Title = .Item(0)
    End With
  Catch ex As Exception
   'MsgBox(ex.Message)
    divUpdatePanel.InnerText = "No Data Found"
  Finally
    _con.Close()
    _con.Dispose()
  End Try
End Sub

Protected Sub LinkButtonEmployees_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButtonEmployees.Click
  loadContent("Employees")
End Sub

问题

当我点击标签时,需要几秒时间来反映数据...我想向用户显示“请稍候加载”消息,该消息应在数据后自动消失显示。

更新: ASPX代码位于UPdatePanel内,因此点击标签会执行异步回发。谢谢。

3 个答案:

答案 0 :(得分:1)

最好将AJAX用于此类事情。线程不会有帮助,因为服务器将等待所有这些线程完成后再将响应返回给客户端。使用消息加载页面,然后使用AJAX加载数据。

答案 1 :(得分:1)

使用Ajax可以部分更新。或者您可以尝试在更新面板中使用异步触发器。 Ajax Update Panels

另外,您可以使用Update Progress来显示指示。像这样 。

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
 </asp:UpdatePanel>

将您的更新面板添加到更新progreess区域。

<asp:updateprogress id="UpdateProgress1" runat="server" associatedupdatepanelid="UpdatePanel1" dynamiclayout="true">
<progresstemplate>
<img src="support/images/loading.gif">
</progresstemplate>
</asp:updateprogress>

答案 2 :(得分:0)

简单的解决方案。将“divUpdatePanel”置于asp:UpdatePanel内。将linkbutton设置为Triggers以实现此目的