input losing src

前端 未结 4 1789
野性不改
野性不改 2021-01-24 23:17

If I use the following code without runat=\"server\" the input\'s src works fine and I see the image coming through.

4条回答
  •  忘了有多久
    2021-01-25 00:12

    You cannot use the <%= %> syntax with server controls (including standard HTML elements with runat="server"). You have two choices:

    • Access the control in the code behind (as an HtmlInputControl) and assign the src attribute using the Attributes property: imageControl.Attributes["src"] = value;
    • Assign the attribute using the databinding syntax (src="<%# %>") and call imageControl.DataBind() from the code behind

提交回复
热议问题