0
當前在我們網站的每個頁面上顯示一條消息。我想改變它,以便它只出現在default.aspx的主頁上。請讓我知道我可以嘗試什麼。以下代碼位於網站母版頁後面的代碼中。我們使用vb.net,但如果有人可以用C#編寫它,我可以將其轉換。VB.NET僅在default.aspx頁面上顯示標籤文本
每一頁上顯示的標籤文本上的代碼:我已經寫
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Using ds As DataSet = SystemDataObject.SystemDataGetMessage()
lblSystemMessage.Text = ds.Tables(0).Rows(0)("SystemMessage_sd").ToString
End Using
End Sub
代碼不工作,我缺少什麼?
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Using ds As DataSet = SystemDataObject.SystemDataGetMessage()
Dim appPath As String = Request.PhysicalApplicationPath
If appPath = "/Default.aspx" Then
lblSystemMessage.Text = ds.Tables(0).Rows(0)("SystemMessage_sd").ToString
End If
End Using
End Sub
您是否嘗試過使用Request.Url並解析它以獲取「default.aspx」?這裏是另一個帖子:在C#http://stackoverflow.com/questions/593709/how-to-get-the-url-of-the-current-page-in-c-sharp – Programmer
當您導航到Default.aspx ,lblSystemMessage.Text代碼行是否受到影響? – Seano666
還沒有嘗試過使用request.url。不確定該怎麼做,不理解我會用它做什麼? @ Seano666當我通過它時,沒有lblSystemMessage.Text被擊中。 – DalW