How can I get the parent page from a User Control in an ASP.NET Website (not Web Application)

后端 未结 9 1068
别跟我提以往
别跟我提以往 2020-12-15 16:54

Just as the subject asks.

EDIT 1

Maybe it\'s possible sometime while the request is being processed to store a reference to the parent page in the user contr

9条回答
  •  借酒劲吻你
    2020-12-15 17:10

    You must use NamingContainer like that:

           try
            {
                if (!string.IsNullOrWhiteSpace(TargetCtrlID))
                {
                    var ctrl = NamingContainer.FindControl(TargetCtrlID);
                    if(ctrl != null)
                        Console.Write("'" + ctrl.ClientID + "'");
                }
            }
            catch
            {
    
            }
    

提交回复
热议问题