how parse asp.net mvc razor view (cshtml) like htm

2019-08-08 03:01发布

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条回答
我想做一个坏孩纸
2楼-- · 2019-08-08 03:35

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.

查看更多
登录 后发表回答