Homepage label value does not receive an updated form on the content page

I have a content page. I am updating the asp value: Homepage label from the content page. the value is updated, but the updated value is not displayed. I tried two methods using

1). defining a property (on the main page) for setting and getting the label value. eg

public string setErrorMsg { get { return lbl1.Text; } set { lbl1.Text = value; } } 

2) by selecting the control (homepage label) on the content page and setting your text. eg.

  Label lblMasterError = this.Page.Master.FindControl("lbl1") as Label; lblMasterError.Text="text is updated form content page"; 

both update the value if I see it in debug mode, but the updated label value does not appear on the content page. What could be the possible reasons for this behavior?

+6
source share
1 answer

I donโ€™t know why I canโ€™t find your label, but I had the same thing as before. this is what works for me:

On the cs homepage:

 public void SetErrorMsg(string ErrorMsg) { this.lbl1.Text = ErrorMsg; } 

From the aspx page code (replace the name myMasterPage w / yours):

  ((myMasterPage)Master).SetErrorMsg("Some error text"); 
+1
source

Source: https://habr.com/ru/post/918491/


All Articles