Reputation: 4001
I have an Html image which I need to update dynamically but without runat="server" my code behind cannot see it.
<img name="MDI" id="detailimg" src="" alt="blankimage.jpg" />
I can access it using Page.Request.Form["MDI"]; but not update it
I need to load the src image at run time so can someone please tell me how I can update the control in my code.
Upvotes: 0
Views: 1838
Reputation: 22619
Do with inline syntax like below
<img name="MDI" id="detailimg" src="<%= getImageSource() %>" alt="blankimage.jpg" />
In codebehind
public string getImageSource()
{
return "urlpath/img.jpeg";
}
More about Inline Syntax
Upvotes: 4
Reputation: 921
as you know if you want to access an element/control from code behind,you should set runat="server" but there is 2 other ways to set properties from code behind
Upvotes: 0
Reputation: 13380
If you want to update via code behind, you have to set runat="server"
If inline is fine, use src="<%= something%>
Otherwise use javascript for example
Upvotes: 0