gpt4 book ai didi

asp.net - ASP.NET 页面中的各种 asp 控件

转载 作者:行者123 更新时间:2023-12-04 06:52:44 26 4
gpt4 key购买 nike

I am creating a products page, where the user selects an option in a radiobuttonlist for example, and then a control with the various options of that product appears in a placeholder or in a div when on of the radiobuttons is selected.

目前这是代码:

aspx:

<form runat="server">
<asp:CheckBoxList ID="Lentes" runat="server" OnClick="EscolheLentes">
<asp:ListItem Value="LU">
Lentes Unifocais
</asp:ListItem>
<asp:ListItem Value="LP">
Lentes Progressivas
</asp:ListItem>
</asp:CheckBoxList>
<asp:PlaceHolder runat="server" ID="PHLentes"></asp:PlaceHolder>
</form>

aspx.vb:
Protected Sub EscolheLentes()
Dim ControlLente As Control
If (Me.Lentes.Items.FindByValue("LU").Selected) Then
ControlLente = LoadControl("LentesUnifocais.ascx")
ElseIf (Me.Lentes.Items.FindByValue("LP").Selected) Then
ControlLente = LoadControl("LentesProgressivas.ascx")
End If
Me.PHLentes.Controls.Add(ControlLente)
End Sub

需要使用一些ajax来加载控件吗?
我朝着正确的方向前进吗?

谢谢。

最佳答案

有几种方法可以实现:

  • 真正的 ASP.Net Web 表单 : 使用 AutoPostback 进行回发并使用其他控件的可见性
  • Javascript :加载页面可能显示的所有数据,并用javascript处理条件显示。只有在一页上显示的数据量有限时,这才是合理的。如果你这样做,你可能想研究 JQuery 或类似的东西。
  • Ajax :仅异步加载您需要的位。您可以使用 MSAjax 框架或 Jquery(或类似的)来执行客户端代码。

  • 第一个选项可能是最快的实现。

    关于asp.net - ASP.NET 页面中的各种 asp 控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2886264/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com