Unable to Update label Outside Update Panel

后端 未结 3 1113
醉话见心
醉话见心 2021-01-20 19:51

I have spent lot of time to investigate how to update label outside Update panel. And finally found something but it does not update label. It works fine if we refresh the p

3条回答
  •  我在风中等你
    2021-01-20 20:50

    Add the register script in code behind event,

    protected void timer_Tick(object sender, EventArgs e)
    {
       if (ScriptManager1.IsInAsyncPostBack)
        {
          //ScriptManager1.RegisterDataItem(Label3, "Hi");
           ScriptManager.RegisterStartupScript(this, this.GetType(), "setLabelOrAnyName", "jQuery(function($) { $('#Label3').text('Whatever')});", true);
        }
     }
    

    This should work.

    Incase if you are not using jQuery library replace code with simple javascript.

提交回复
热议问题