how parse asp.net mvc razor view (cshtml) like html parser in c#

五迷三道 提交于 2019-12-11 03:36:23

问题


I want to parse razor view file in c# . I have also used Html Agility Pack to parse razor view file but it failed to save correct file contents.

Basically i want to change some html elements inner html by server side using c#

<div id="content1">
<p>this contents i want to change </p>
<span>contes</span>
</div>

i want to change content1 inner html by c# like this

<div id="content1">
    <span>@Function.gethtml()</span>
    </div>

I have used html agility pack to change inner html contents but it is not parsing razor syntax function like

@Url.Content("abc.css") and other function

For more information

I have created a project in asp.net mvc3 for shoes and garments shops.Now i want to change css and html dynamically.i want to extract inner html from any html template file where element id will be "content1" and place this inner html in cshtml file where element id is "content1

Simply i want razor file parser that can parse both html and razor syntax like html parser

Is there any way to parse razor view file and it html elements. Any Other solution


回答1:


You want to access / modify razor content using server side content.

But MVC is a different way of building websites/applications to webforms.

There are now server side controls or webcontrols. You can use JQuery to do same.



来源:https://stackoverflow.com/questions/13780232/how-parse-asp-net-mvc-razor-view-cshtml-like-html-parser-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!