Thursday, January 17, 2019

How to Add HTML Attribute to html tags from c# code

In this article i have explain how to add image source from c# code behind

Step 1-
insert the html image tag into your aspx page
<img id="ImageId" runat="server" width="100" height="100" />

here i have add image tag into aspx page. the tag ID is ImagesId

Step 2-
Now add the image source to image tag from c# code

 string imageUrl = "images/bg.jpg";
 ImageId.Attributes.Add("src", imageUrl);


No comments:

Post a Comment

Featured Post

What is JavaScript? What is the role of JavaScript engine?

  The JavaScript is a Programming language that is used for converting static web pages to interactive and dynamic web pages. A JavaScript e...