简体   繁体   中英

set property for user control

hi i have a userControl with this property :

public string UserImg { get; set; }
 protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            userImg.Src = UserImg;
        }
    }

and markup :

<img class="userImg" src="" width="90" id="userImg" runat="server" />

when i use this userControl and set it in code :

StudentDetail1.UserImg = string.Format("AdminPanel/StudentsPic/{0}",query.Pictuer);

(query is my linq to entite's query that contain image name like 'person.png').

image is'not displayed,because i have got an extra "UserControl" below:

<img src="UserControl/AdminPanel/StudentsPic/man.png" id="right_StudentDetail1_userImg" class="userImg" width="90">

how can i remove "UserControl" from src.

尝试使用

StudentDetail1.UserImg = string.Format("../AdminPanel/StudentsPic/{0}",query.Pictuer);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM