Question : Mix HTML and VB.NET

Hi

I need to transfer the following code mix of C# and HTML to VB.NET and HTML:

1:
2:
3:
4:
5:
<%# IfCompare(ImageHelper.IsImage((string)Eval("AttachmentExtension")), true,

"<div style=\"text-align:center;width: 350px;\"><div style=\"font-size: 11px;line-height: 12px;position:relative;z-index:1000;margin:auto;width:140px;\"><a target=\"_blank\" href=\"" + GetAttachmentUrl(Eval("AttachmentName"), Eval("NodeAliasPath")) + "\"><img style=\"border: none;\" src=\"" + GetAttachmentIconUrl(Eval("AttachmentExtension"), null) + "\" alt=\"" + Eval("AttachmentName") + "\" /></a><p>" + ResHelper.GetString("attach.openfile") + "</p></div></div>",

"<img src=\"" + GetAttachmentUrl(Eval("AttachmentName"), Eval("NodeAliasPath")) + "?maxsidesize=1000\" alt=\"" + Eval("AttachmentName", true) + "\" />") %>


I already managed the VB.NET part part cant get the HTML part to work:

1:
2:
3:
4:
5:
<%# IfCompare(ImageHelper.IsImage(Eval("AttachmentExtension").ToString), 0,

"<div style=\"text-align:center;width: 350px;\"><div style=\"font-size: 11px;line-height: 12px;position:relative;z-index:1000;margin:auto;width:140px;\"><a target=\"_blank\" href=\"" + GetAttachmentUrl(Eval("AttachmentName"), Eval("NodeAliasPath")) + "\"><img style=\"border: none;\" src=\"" + GetAttachmentIconUrl(Eval("AttachmentExtension"), null) + "\" alt=\"" + Eval("AttachmentName") + "\" /></a><p>" + ResHelper.GetString("attach.openfile") + "</p></div></div>",

"<img src=\"" + GetAttachmentUrl(Eval("AttachmentName"), Eval("NodeAliasPath")) + "?maxsidesize=1000\" alt=\"" + Eval("AttachmentName", true) + "\" />") %>


Mike
 
VS Screenshot
325605
 
 
VB Code
 
 
C# Code
 

Answer : Mix HTML and VB.NET

The escape character for a quotation mark (") in VB is a double quotation mark (""). Since you are trying to output HTML, I suggest changing the C# escape for a quotation mark (\") to apostrophes (').

So this line:

"<div style=\"text-align:center;width: 350px;\"><div style=\"font-size: 11px;line-height: 12px;position:relative;z-index:1000;margin:auto;width:140px;\"><a target=\"_blank\" href=\"" + GetAttachmentUrl(Eval("AttachmentName"), Eval("NodeAliasPath")) + "\"><img style=\"border: none;\" src=\"" + GetAttachmentIconUrl(Eval("AttachmentExtension"), null) + "\" alt=\"" + Eval("AttachmentName") + "\" /></a><p>" + ResHelper.GetString("attach.openfile") + "</p></div></div>",

become:

"<div style='text-align:center;width: 350px;'><div style='font-size: 11px;line-height: 12px;position:relative;z-index:1000;margin:auto;width:140px;'><a target='_blank' href='" + GetAttachmentUrl(Eval("AttachmentName"), Eval("NodeAliasPath")) + "'><img style='border: none;' src='" + GetAttachmentIconUrl(Eval("AttachmentExtension"), null) + "' alt='" + Eval("AttachmentName") + "' /></a><p>" + ResHelper.GetString("attach.openfile") + "</p></div></div>",
Random Solutions  
 
programming4us programming4us