WebPage.aspx
<asp:Button ID="Button1" runat="server" Text="Submit" onclick="Button1_Click" />
<asp:Timer ID="Timer1" runat="server" Interval="1000"
OnTick="StatusTimer_Tick" Enabled="False" />
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1"/>
</Triggers>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server"&开发者_如何学运维gt;
<ContentTemplate>
<asp:Label ID="Label2"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" Event="Click"/>
</Triggers>
</asp:UpdatePanel>
WebPage.aspx.cs
protected void Timer1_Tick(object sender, EventArgs e)
{
Label1.Text = "Refreshed at : " + DateTime.Now.ToLongTimeString();
}
protected void Button1_Click(object sender, EventArgs e)
{
Timer1.Enabled = true;
//Call some web-service
XMLComparisonService.Service1SoapClient oService = new XMLComparisonService.Service1SoapClient();
oService.XMLComparison();
}
- So
Button1_Click
enablesTimer1
. Label1
inUpdatePanel1
should get refreshed every 1 second! (withLabel1
printing the current time)Button1_Click
also calls the web-service method "XMLComparison"
But Label1
doesnt refresh after the web-service method "XMLComparison" gets called...
Is anything wrong with my approach?
Regards -Parag
It looks like you are calling a webservice, but not waiting for a response before updating the page.
Here is an example
http://www.codeproject.com/KB/webservices/WebServiceConsumer.aspx
精彩评论