locked
Change label text which is inside updateprogress from code behind RRS feed

  • Question

  • User-1096956769 posted

    Hi ,

    How to change label text which is inside updateprogress from code behind ? 

    I tried with this code , but it did not work ? 

    Label ProgressMessage = UpdateProgress1.FindControl("lblProgressMessage") as Label;
    if (ProgressMessage != null)
    {
    ProgressMessage.Text = "10% ";
    }

    Value of lblProgressMessage changes in code behind. but its not displaying in web page

    Please help me out 

    Friday, January 9, 2015 5:30 AM

Answers

All replies

  • User-1034726716 posted

    AFAIK, The UpdateProgress is not accessible until very late in the page's lifecycle.  It accessible in the Page_PreRenderComplete event. 

    protected void Page_PreRenderComplete(object sender, System.EventArgs e)
    {
    	((Label)UpdateProgress1.FindControl("lblProgressMessage")).Text = "Whatever you want it to say here.";
    }

    Friday, January 9, 2015 5:52 AM
  • User-1096956769 posted

    Thank you vinz. It works but as per condition i need to change text value. it gets updated in code behind but not shown in webpage

    Eg : 

    Event :

    btn_event

    {

    function1();

    function2();

    }

    void function1(){

    Label)UpdateProgress1.FindControl("lblProgressMessage")).Text = "function one .";

    }

    void function2(){

    Label)UpdateProgress1.FindControl("lblProgressMessage")).Text = "function two.";

    }

    Friday, January 9, 2015 7:00 AM
  • User-1034726716 posted

    Does your code in your function works?

    Friday, January 9, 2015 7:09 AM
  • User-1096956769 posted

    Yes its working. value of label changes but it not displaying in aspx page 

    <asp:UpdateProgress runat="server" ID="UpdateProgress1" AssociatedUpdatePanelID="updGrid">
    <ProgressTemplate>
     
    <div style="; top: 40%; left: 30%; height: 80%; width: 40%; z-index: 100001;
    background-image: url('~/images/loading.gif'); background-repeat: no-repeat;
    background-;">
    <center>
     
    Progressing ...
     
    <h3> <asp:Label runat="server" ID="lblProgressMessage" ></asp:Label></h3>
     

    </center>
    </div>
    </ProgressTemplate>
    </asp:UpdateProgress>

    Friday, January 9, 2015 9:57 AM
  • User-1034726716 posted

    Does it change when you set the value at Page_PreRenderComplete event?

    Friday, January 9, 2015 10:02 AM
  • User-1096956769 posted

    Yes it changed in Page_PreRenderComplete event, but I need to change that label text in different function. Label text gotta change dynamically not as a static one 

    Friday, January 9, 2015 10:07 AM
  • User-1034726716 posted

    Yes it changed in Page_PreRenderComplete event, but I need to change that label text in different function. Label text gotta change dynamically not as a static one 

    Since the UpdateProgress control can only be updated at Page_PreRenderComplete then you have to move your function logic to change the text within that event. 

    You may also try to look at this links for some workarounds using different approach:

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 9, 2015 10:22 AM