简体   繁体   中英

returning plain html from page method

I would like for a webmethod to return a string of pure html. The html isnt anything too fancy, a table and a couple form fields populated with values from a database.

Is their an easy way to build html within html? currently I am just dynamically building up a string, but it just feels dirty.

I could make a full blown aspx page, and then just strip out the bits I dont want from the resulting page leaving the plain html behind. but that also feels dirty.

Or there is the templating option (nvelocity etc) but thats seems like overkill.

any suggestion on something more efficient.

Tx

  1. You can build a template file like xml to write the basic of your html with {0}{1}{2}{n} to put static content in it
  2. Manipulate this template server side as you wish. You can add a list of data into this template.
  3. Create a literal control on your page.
  4. Put the server side created html in to you literal control. (myLiteral.Text)

You can create a basic asp.net file and add the html template in it by adding it from the literal control.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM