How to get a label value from web user control to a content page using master page

前端 未结 3 574
误落风尘
误落风尘 2021-01-27 11:24

I have a web user control book.ascx and a formview:





        
3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-27 12:09

    you wanted to get it on the client side via javascript?

    getElementById('<%=lblBookId.ClientID%>')
    

    I would also recommend getting firebug for firefox and then you can take a look at the generated html of the webpage. You'll also be able to step though and debug your javascript.

    if trying to find this on the server side try this.

    ContentPlaceHolder ph = Page.Master.FindControl("ContentPlaceHolder1");   
    UserControl Uc = ph.Controls(0);
    FormView fv = up.FindControl("fv");
    Label label = fv.FindControl("lblBookId");
    label.Text = "Hi there"; 
    

    if this doesn't work, you can get the idea. keep drilling down until you find what you're looking for.

提交回复
热议问题