2010-03-21 24 views
0
string rowString = "<tr id=\"row1\" bgcolor=\"#FFFFFF\" onMouseOver=\"this.bgColor='#EEEEEE';\" onMouseOut=\"this.bgColor='#FFFFFF';\" style=\"cursor:pointer;\">" + 
     "<td bgcolor=\"#FFFFFF\"><img src=\"images/"+"-companylogofilename-"+"\" width=\"108\" height=\"32\" alt=\""+"-companyname-"+"\" /></td>" + //turkish.airlines.jpg airlineiconfilename, airline name 
    "<td class=\"table_content\">{0}</td>" + 
    "<td class=\"table_content\">{1}</td>" + 
    "<td class=\"table_content\">{2}</td>" + 
    "<td class=\"table_content\">{3}</td>" + 
    "<td class=\"table_content\">{4}</td>" + 
    "<td class=\"table_content\"><table width=\"98%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" + 
    "<tr><td class=\"table_content\">{5}</td>" + 
    "<td width=\"20\" align=\"right\">" + 
    "<a href=\"default.aspx\" onClick=\"return hs.htmlExpand(this, { headingText: '{6} - {7}', width: 600, height: 215, targetX: 'row1 400px', targetY: 'row1 40px' })\">" + 
    "<img src=\"images/arrow.png\" width=\"13\" height=\"16\" border=\"0\" class=\"tip\" onMouseOver=\"tooltip('Click for Details.');\" onMouseOut=\"exit();\" />" + 
    "</a>"; 

    accordionHTML.Append(String.Format(rowString, 
     flight.Get_AirlineCode(), 
     flight.Get_Clase(), 
     flight.Get_Departure(), 
     flight.Get_DeprtDate(), 
     flight.Get_DeprtTime(), 
     flight.Get_Destination(), 
     flight.Get_Departure(), 
     flight.Get_Destination())); 

嗨, 有人可以幫我找到上面的錯誤嗎? 我收到一個錯誤,因爲「輸入字符串不正確!」; 由於提前,stringbuilder中的錯誤

+0

你應該叫'AppendFormat'。另外,你應該使用'@'字符串。此外,你有XSS洞。你應該使用模板引擎。 – SLaks 2010-03-21 15:14:28

+0

同樣的事情發生,有輸入字符串,我不能看到sthg錯了! – Kubi 2010-03-21 15:15:43

+0

我的意思是作爲一般性建議,而不是解決問題。 – SLaks 2010-03-21 15:16:03

回答

1

你的直列onClick處理程序轉義獨立括號中的對象字面:

onClick=\"return hs.htmlExpand(this, { headingText: '{6} - {7}', width: 600, height: 215, targetX: 'row1 400px', targetY: 'row1 40px' })\">" 

你需要寫this, {{ headingText... }}