ASP.NET遇到問題---空引用異常

Problem2:

 下面的紅色部分出錯

提示:

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim i As Integer
        For i = 1 To 6
            Dim newhl As New HyperLink
            Dim newlabel As Label
            newlabel.Text = " "
            newhl.Font.Size = 12
            newhl.Font.Bold = True
            newhl.Text = CStr(i)
            newhl.NavigateUrl = "?n=" + CStr(i)
            newhl.ID = "h1" + CStr(i)
            DIV1.Controls.Add(newhl)
            DIV1.Controls.Add(newlabel)
        Next
        If Request("n") = " " Then
            Image1.ImageUrl = "~/images/01.jpg"
        Else
            Image1.ImageUrl = "~/images/0" + Request("n") + ".jpg"
        End If
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>圖象瀏覽</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div id="DIV1" runat="server" style="width: 345px; height: 27px">
        </div>
        <br />
        <br />
        <asp:Image ID="Image1" runat="server" Height="200px" /></div>
    </form>
</body>
</html>
 

發佈了55 篇原創文章 · 獲贊 4 · 訪問量 29萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章