ASP.NET中拼接字符串的另一實現:Response.Write
作者:jetlee
文章介紹了asp.net中拼接字符串的方法。拼接字符串除了用在SQL注入,鏈接個變量寫入查詢之外,使用Response.Write()也可以拼接字符串。
一直以為拼接字符串只能用在SQL注入,鏈接個變量寫入查詢,今天才發現Response.Write()也可以拼接字符串,留個記號。
代碼過程如下
1. 頁面源碼:
- Response.Write("< script language=javascript>confirm('是否刪除')< /script"); //這里缺少一個“>”
- //拼接字符串
- Response.Write("顯示信息");
執行結果:沒有反應
2. 頁面源碼:
- Response.Write("< script language=javascript>confirm('是否刪除')< /script"); //這里缺少一個“>”
- //拼接字符串
- Response.Write(">顯示信息"); //這里多了一個“>”
執行結果:先彈出提示信息,確定后,顯示“顯示信息”字樣
3. 頁面源碼:
- Response.Write("顯示信息");
- //拼接字符串
- Response.Write("< script language=javascript>confirm('是否刪除')< /script"); //這里缺少一個“>”
執行結果:先顯示字符,后彈出提示框,雖然少了一個“>”,但結果還是正確的
【編輯推薦】
責任編輯:book05
來源:
cnblogs