RajeevKRanjan

I have this code for VB.NET


Dim UName As String
Dim thisName As String
thisName = "<a class=""lastPostLink"" href=""Hello.aspx id=" & UserId & """>" & UName & "</a>"

But I want it in C#. Plz solve this problem. Its urgent

Thanks



Re: Visual C# General Store HTML anchor tag in a C# variable

Bravo9

string uName = "Test";

const string anchorTag = "<a class=\"lastPostLink\" href=\"Hello.aspx id=\"{0}\">{1}</a>";

string thisName = string.Format(anchorTag, 100, uName);





Re: Visual C# General Store HTML anchor tag in a C# variable

OmegaMan

A more elegant way would be this since single or double quotes are allowed.

Code Snippet


string tag = string.Format(@"<a class='lastPostLink' href='Hello.aspx id={0}'>{1}</a>", UserId, UName);






Re: Visual C# General Store HTML anchor tag in a C# variable

VS_Programmer

You can also simply 'add' the strings.

string UName;

string thisName = "<a class=\"lastPostLink\" href=\"Hello.aspx.id=" + UserId + "\">\"" + UName + "</a>";

Hope this helps!





Re: Visual C# General Store HTML anchor tag in a C# variable

Martin Xie - MSFT

Thank you all for your active participation and valuable experience!Smile




Re: Visual C# General Store HTML anchor tag in a C# variable

Kiran Patil

Hi Friend,

For Ur Future Ref. for VB TO .NET CODE

http://www.carlosag.net/Tools/CodeTranslator/Default.aspx

Just copy ur code here and njoy!!!

This is UR Help for future.

Thanks

Keep Sharing Knowledge

Genuine,
Mr.Kiran Patil





Re: Visual C# General Store HTML anchor tag in a C# variable

OmegaMan

Kiran Patil wrote:
Hi Friend,For Ur Future Ref. for VB TO .NET CODE

http://www.carlosag.net/Tools/CodeTranslator/Default.aspx

Just copy ur code here and njoy!!!

This is UR Help for future.


Two things, UR, is that short for Your Secondly the link is no panacea here is the output of the user's code

string UName;
string
thisName;
thisName = ("<a class=\"lastPostLink\" href=\"Hello.aspx id="
+ (UserId + ("\">"
+ (UName + "</a>"))));