makdu
makdu

Reputation: 946

asp:literal with img not aligning

I am trying to give a padding to left space in the image in the asp:literal

 <asp:Literal ID="litPageHeader" runat="server" meta:resourcekey="litPageHeaderResource1"
            Text='<img style="padding-left:50px;" src="images/en/HdrFtr/sh-traveldetails.gif" alt=" MY Travel Details"  />' />

but when i check the source code for the page, i am getting

<img alt="Your Travel Details" src="images/en/HdrFtr/sh-traveldetails.gif">

the padding effect is not coming .. Is there anything missing

Upvotes: 1

Views: 97

Answers (1)

Jerreck
Jerreck

Reputation: 3030

Hmm, not 100% sure why that's happening. I'd bet is has something to do with some weird way the single and double quotes are being interpreted.

However, I know for sure that setting the Text property in the code behind during some page event like Page_Load() would work. I've already used code similar to this today:

protected void Page_load(Object sender, EventArgs e)
{
    litPageHeader.Text = "<img style=\"padding-left:50px;\" src=\"images/en/HdrFtr/sh-traveldetails.gif\" alt=\" MY Travel Details\"  />";
}

Upvotes: 1

Related Questions