我與被包含在.ASPX.CS頁面下面的代碼工作...ASP.NET自動轉義字符?
img = "<img src=\"" + yellow + "\" align=\"middle\" onclick=\"alert('You are the current high bidder but the auction's minimum bid reserve has not been met. You need to increase your max bid until the reserve has been met to have a chance in winning this domain auction.');return false;\" class=\"sBtnImg\" alt=\"\" />";
它被寫入到.aspx頁面中一個ASP中:中繼器使用以下...
<%# getAuctionFlag(Eval("AuctionAmt").ToString(), Eval("WinningBid").ToString(), Eval("UserMaxBid").ToString(), Eval("AuctionTypeDesc").ToString(), "", Eval("BidStatus").ToString())%>
我遇到的問題是警報在拍賣中包含單引號,並且我所有嘗試轉義它都失敗了。我試過\'和',但.NET在它被呈現爲HTML之前轉義它。所以我結束了......
onclick="alert('TEXTHERE' TEXTHERE');return false;"