請問如何讓中文字體能正常顯示在textbox裡?? 謝謝!!! |
尚未結案
|
Lazy
一般會員 發表:2 回覆:1 積分:0 註冊:2005-05-14 發送簡訊給我 |
以下為小弟的程式碼...
程式目的是取得網站之資訊,呈現在textbox裡,再存入記事本
但在textbox裡不能顯示中文字體...
請不吝賜教~~~ Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.IO
Imports System.Net Public Class WebForm1
Inherits System.Web.UI.Page Private Sub Get_URI_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Get_URI.Click
Get_URI_HTML(URI_Box.Text)
End Sub Private Sub Get_URI_HTML(ByVal uri As String)
'HTML_Box.Clear()
Dim request As WebRequest = Nothing
Dim response As WebResponse = Nothing
Dim reader As StreamReader = Nothing
Try
request = WebRequest.Create(uri)
response = request.GetResponse
reader = New StreamReader(response.GetResponseStream)
reader = New StreamReader(response.GetResponseStream)
HTML_Box.Text = reader.ReadToEnd
Catch ex As Exception
HTML_Box.Text = ex.Message
Finally
If Not (reader Is Nothing) Then
reader.Close()
End If
If Not (response Is Nothing) Then
response.Close()
End If
End Try
End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim file1 As FileInfo = New FileInfo("C:\Inetpub\wwwroot\getcode_01\newfile.txt")
'file1.Create()
Dim fileinfo1 As New FileInfo("C:\Inetpub\wwwroot\getcode_01\newfile.txt")
Dim sw As StreamWriter = fileinfo1.AppendText
sw.Write(HTML_Box.Text)
sw.Flush()
sw.Close()
End Sub End Class 希望各位先進為我解答~~
感激~~~ 發表人 - lazy 於 2005/07/28 15:04:25
|
yangshengfa
一般會員 發表:1 回覆:16 積分:3 註冊:2003-09-06 發送簡訊給我 |
|
Lazy
一般會員 發表:2 回覆:1 積分:0 註冊:2005-05-14 發送簡訊給我 |
首先感謝您的回答!!! Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim file1 As FileInfo = New FileInfo("C:\Inetpub\wwwroot\getcode_01\newfile.txt") Dim fileinfo1 As New FileInfo("C:\Inetpub\wwwroot\getcode_01\newfile.txt")
Dim sw As StreamWriter = fileinfo1.AppendText
sw.Write(HTML_Box.Text)
sw.Flush()
sw.Close()
End Sub 以上程式碼欲將textbox裡頭的內容存至記事本...
執行後卻顯示"""有潛在危險 Request.Form 的值已從用戶端 (HTML_Box="<html xmlns:y="urn:t...") 偵測到。"""
描述: 要求驗證偵測到具有潛在危險的用戶端輸入值,對這個要求的處理已經中止。這個值可能表示有人嘗試危害應用程式的安全性,例如跨站台的指令碼處理攻擊。您可以在 Page 指示詞或 組態區段中設定 validateRequest=false 來停用要求驗證。但是我們強列建議您的應用程式應該明確地檢查所有這類的輸入。 例外詳細資訊: System.Web.HttpRequestValidationException: 具有潛在危險 Request.Form 的值已從用戶端 (HTML_Box="<html xmlns:y="urn:t...") 偵測到。 原始程式錯誤: 在執行目前 Web 要求期間,產生無法處理的例外狀況。如需有關例外狀況來源與位置的資訊,可以使用下列的例外狀況堆疊追蹤取得。 堆疊追蹤: [HttpRequestValidationException (0x80004005): 具有潛在危險 Request.Form 的值已從用戶端 (HTML_Box="<html xmlns:y="urn:t...") 偵測到。]
System.Web.HttpRequest.ValidateString(String s, String valueName, String collectionName)
System.Web.HttpRequest.ValidateNameValueCollection(NameValueCollection nvc, String collectionName)
System.Web.HttpRequest.get_Form() 113
System.Web.UI.Page.GetCollectionBasedOnMethod()
System.Web.UI.Page.DeterminePostBackMode()
System.Web.UI.Page.ProcessRequestMain()
System.Web.UI.Page.ProcessRequest()
System.Web.UI.Page.ProcessRequest(HttpContext context)
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication IExecutionStep.Execute()
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) 87
之錯誤訊息~~~ 請大哥為小弟指點迷津~~ 謝謝!!
|
yangshengfa
一般會員 發表:1 回覆:16 積分:3 註冊:2003-09-06 發送簡訊給我 |
ValidateRequest
指示是否應該執行要求驗證。如果是 true,則要求驗證會根據潛在危險值的硬式編碼清單,檢查所有的輸入資料。如果找到符合的資料,便會擲回 HttpRequestValidationException 類別。預設值是 true。
電腦組態檔 (Machine.config) 中會啟用這項功能。您可在應用程式組態檔 (Web.config) 中或頁面上將這項屬性設定為 false,停用這項功能。 注意 :
這項功能可減少在直接使用網頁或 ASP.NET 應用程式時,受到跨網站指令碼攻擊的風險。沒有適當驗證使用者輸入的應用程式可能會遭受許多種錯誤輸入的攻擊,包括跨網站的指令碼和 SQL Server 引入攻擊 (Injection Attack) 等。最好的防範方式,還是謹慎評估應用程式中所有形式的輸入,並確定這些輸入都經過適當的驗證或編碼,或是確定應用程式會在操作資料或將資訊傳回至用戶端前就先行逸出。如需跨網站指令碼的詳細資訊,請參閱 http://www.cert.org/advisories/CA-2000-02.html。 這是 ASP.NET 防範網站被攻擊的檢查方式,你可以用下列的方式來關閉驗證功能。
方式一:
<%@ Page language="c#" ... ValidateRequest="false" %>方式二: 在 Web.config 加入 發表人 - yangshengfa 於 2005/08/07 07:46:24 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |