Okay, hopefully a simple one,
Labels are not updating here when update is called on each update panel and only work when finished,
script manage is no the master page allowing for partial rendering already as well. but still not working, any ideas? Is what i'm trying to do not correct?
please don't just post a link, actully show me where i'm going wrong. is my understaing of update panels not correct? How can I achieve this? Thanks
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<div>
<asp:Button runat="server" ID="button1" OnClick="button1_Click" />
</div>
<asp:UpdatePanel runat="server" ID="up1" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label runat="server" ID="label1UP1" Text="This is the first label"></asp:Label>
</ContentTemplate>
<%-- <Triggers>
<asp:PostBackTrigger ControlID="button1" />
</Triggers>--%>
</asp:UpdatePanel>
<asp:UpdatePanel runat="server" ID="UP2" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label runat="server" ID="label1UP2" Text="This is the second label label"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel runat="server" ID="UP3" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label runat="server" ID="label1UP3" Text="This is the third label label"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
protected void button1_Click(object sender, EventArgs e)
{
ViewState["el"] = methodone();
label1UP1.Text = ViewState["el"].ToString();
label1UP1.DataBind();
up1.Update();
System.Threading.Thread.Sleep(10000);
string label2 = methodtwo();
label1UP2.Text = label2.ToString();
label1UP2.DataBind();
UP2.Update();
System.Threading.Thread.Sleep(10000);
string label3 = methothree();
label1UP3.Text = label3.ToString();
label1UP3.DataBind();
UP3.Update();
}
This is what you need to do:
Do a postback three times, with a delay using javascript Eg:
`
<script>
function callBackend(labelValue){
document.getElementById("HLabelName").value = labelValue;
__doPostBack("HLabelName", ""); //This causes a postback
}
</script>
<asp:HiddenField runat="server" ID="HLabelName" OnValueChanged="HLabelName_OnValueChanged" ClientIDMode="Static"/>
` 2. Each time set a hiddenfield value to identify the label to update 3. In the backend event, get the hiddenfield value and update the corresponding label
In the backend:
//This triggers the first event
protected void button1_Click(object sender, EventArgs e)
{
//Then call JS function to update label1
//This triggers the second event
ScriptManager.RegisterStartupScript(this, GetType(), "CallLabel3", "setTimeout(callBackend('label2'), 3000)", true);
}
protected void HLabelName_OnValueChanged(object sender, EventArgs e)
{
switch (this.HLabelName.Value)
{
case "label2":
//Update Label 2 here Value here
//This triggers the third event
//Then call JS function to update label3
ScriptManager.RegisterStartupScript(this, GetType(), "CallLabel3", "setTimeout(callBackend('label3'), 3000)", true);
break;
case "label3":
//Update Label 3 here
break;
}
}
This should do the trick for you