Pass values from page to user control

前端 未结 5 1572
别那么骄傲
别那么骄傲 2021-02-14 07:21

I am storing name and last name in two labels in main page. I also have those values in a class (class doesnt do much but i am using them for future expansion). I have a user co

5条回答
  •  既然无缘
    2021-02-14 08:05

    You need to create properties on your control to hold these values; then from the page code, simply assign the values to the properties in the control.

    On your control, you can have something like

    public string FirstName
    {
      get {
         if (ViewState["FirstName"] == null)
            return string.Empty;
         return ViewState["FirstName"].ToString();
    
          }
          set {
               ViewState["FirstName"] = value;
          }
    }
    

提交回复
热议问题