我尝试使用 ASP.NET 和 VB 创建动态 Web 解决方案。
我的网页如下所示:
<div id="menu" style="position:relative;text-align:center">
<asp:PlaceHolder runat="server" id="PHimg1" />
<asp:PlaceHolder runat="server" id="PHimg2" />
<asp:PlaceHolder runat="server" id="PHimg3" />
<br />
<asp:PlaceHolder runat="server" id="PHimg4" />
<asp:PlaceHolder runat="server" id="PHimg5" />
<asp:PlaceHolder runat="server" id="PHimg6" />
<br />
<asp:PlaceHolder runat="server" id="PHimg7" />
<asp:PlaceHolder runat="server" id="PHimg8" />
<asp:PlaceHolder runat="server" id="PHimg9" />
</div>
VB部分是这样的:
Public Class index
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Load_Main()
End Sub
Protected Sub Load_Main()
Dim img1 As New ImageButton()
Dim img2 As New ImageButton()
Dim img3 As New ImageButton()
Dim img4 As New ImageButton()
Dim img5 As New ImageButton()
Dim img6 As New ImageButton()
img1.ImageUrl = "./resources/EssenTrinken.png"
img1.OnClientClick = "Load_Eating()"
img2.ImageUrl = "./resources/Einkaufen2-black.png"
img3.ImageUrl = "./resources/Special-black.png"
img4.ImageUrl = "./resources/KosmetikWellness.png"
img5.ImageUrl = "./resources/KulturGeschichte.png"
img6.ImageUrl = "./resources/Unterhaltung2-black.png"
PHimg1.Controls.Add(img1)
PHimg2.Controls.Add(img2)
PHimg4.Controls.Add(img3)
PHimg5.Controls.Add(img4)
PHimg7.Controls.Add(img5)
PHimg8.Controls.Add(img6)
End Sub
Protected Sub Load_Eating()
Dim img1 As New ImageButton()
Dim img2 As New ImageButton()
Dim img3 As New ImageButton()
Dim img4 As New ImageButton()
Dim img5 As New ImageButton()
Dim img6 As New ImageButton()
img1.ImageUrl = "./resources/zurueck.png"
img2.ImageUrl = "./resources/Bars2.png"
img3.ImageUrl = "./resources/Cafe.png"
img4.ImageUrl = "./resources/FastFood2.png"
img5.ImageUrl = "./resources/Restaurant.png"
img6.ImageUrl = "./resources/Baeckerei.png"
PHimg1.Controls.Add(img1)
PHimg2.Controls.Add(img2)
PHimg3.Controls.Add(img3)
PHimg4.Controls.Add(img4)
PHimg5.Controls.Add(img5)
PHimg6.Controls.Add(img6)
End Sub
End Class
我希望如果我单击其中一个图像按钮,则首页的孔外观会动态变化,而无需加载新的孔页。所以我为此定义了几个 PlacHolder。
如果我运行 web 应用程序,但如果我按下按钮,则该功能不起作用。
我检查了来源并找到了这个标签:
<input type="image" name="ctl03" src="./resources/EssenTrinken.png" onclick="Load_Eating();" />
这个解决方案有什么问题?