I am working on project using asp.net mvc3 C# . I want to change some html element
attributes by c# like width , height etc. I have a simple (_Layout.cshtml) file
<html> <head>
<link href="@Url.Content("file.css")" rel="stylesheet" type="text/css" />
<body>
<a href="#" id="link1" title="@Function.ConfigElement("FacebookLink")" ></a>
</body>
</head> </html>
So i am using html agility pack to load and save this file
HtmlDocument doc= new HtmlDocument();
doc.load("_Layout.cshtml");
doc.GetElementbyId("link1").Attributes.Add("title", "@Function.ConfigElement("NewLink")");
doc.save("_Layout.cshtml");
After saving file output is like this
<html> <head>
<link href="@Url.Content("file.css")"="" rel="stylesheet" type="text/css" />
<body>
<a href="#" id="link1" title="@Function.ConfigElement("NewLink")"="" ></a>
</body>
</head> </html>
in (link href)
and (anchor title)
saving some extra characters
How can i avoid this problem .. Is there any other solution for parse html in c# for asp.net mvc.
Actually I want to add some server side function in these html element attributes