1
@{
Layout = null;
string root = Server.MapPath("~");
string path = @"Content\galleries\galleries\";
DirectoryInfo Dir = new DirectoryInfo(root + path + (string)ViewData["Name"]);
FileInfo[] FileList = Dir.GetFiles("*.jpg");
string response = "";
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<script type="text/javascript">
jQuery(function ($) {
var array = new Array();
var galleryname = '@ViewData["Name"]';
@for (int i = 0; i < FileList.Length; i++)
{
string s = @"
var path = '../Content/galleries/galleries/" + @ViewData["Name"] + @"/" + @FileList[i].Name + @"';
var thumbpath = '../Content/galleries/galleries/" + @ViewData["Name"] + @"/thumbs/" + @FileList[i].Name + @"';
array[" + i.ToString() + @"] =
{
image: path,
title: '" + @ViewData["Name"] + @"',
thumb: thumbpath,
url: path
};";
response += s;
}
@response
이 내 코드입니다. 동적으로 asp.net 함께 일부 자바 스크립트 코드를 작성하고 싶습니다. @response와 함께 'response'문자열을 출력 할 때, 페이지 소스에서 모든 문자가 & # 39로 변경된 것을 볼 수 있습니다. . 모든 길은 나쁘다. 또한 루프 내부에 Response.Write (s)를 사용하여 시도했지만 '문자는 변경되지 않았습니다. 그러나 생성 된 코드는 doctype과 물론 아무것도 작동하지 않는 페이지 소스의 맨 처음에 배치됩니다.표시 특수 문자
이러한 문제를 해결하는 방법은 무엇입니까? 또는 적어도 그들 중 하나;)? 아니면 다른 방법이 있습니까? 출력 원시 텍스트