关于将通用例程移至 App_Code 类的问题

发布于 2024-08-19 12:37:43 字数 711 浏览 5 评论 0原文

我有一些想要在页面之间共享的通用代码,并且我一直在使用 App_Code 类,这很棒,但我也想使用影响下拉列表示例的代码:

Sub Set_FirmType(ByVal Sender As Object, ByVal E As EventArgs)

    subcategories.Visible = "false"
    supplycategories.Visible = "false"
    supplytypes.Visible = "false"
    CityData.Visible="True"
    CityDropDown.Visible="False"
    CityDropDown.Items.Clear()

    If DropFirmType.SelectedValue = "funeralhomes||FH" Then
        CountryDropDown.ClearSelection()
        CountryDropDown.Items.FindByValue("United States").Selected = True
        CountryDropDown.Enabled = False
        StateDropDown.Enabled = True
        getStateDropDown("1")
    End If
End Sub

他们是否可以将其放入我的 App_Code 中班级?

提前致谢!

I have some common code that I would like to share between pages and I have been messing around with App_Code classes which is great but I would also like to use code that affects drop down lists example:

Sub Set_FirmType(ByVal Sender As Object, ByVal E As EventArgs)

    subcategories.Visible = "false"
    supplycategories.Visible = "false"
    supplytypes.Visible = "false"
    CityData.Visible="True"
    CityDropDown.Visible="False"
    CityDropDown.Items.Clear()

    If DropFirmType.SelectedValue = "funeralhomes||FH" Then
        CountryDropDown.ClearSelection()
        CountryDropDown.Items.FindByValue("United States").Selected = True
        CountryDropDown.Enabled = False
        StateDropDown.Enabled = True
        getStateDropDown("1")
    End If
End Sub

Is their a way to put this in my App_Code class?

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幽梦紫曦~ 2024-08-26 12:37:43

听起来您有一个子例程可以切换多个控件的可见性并在下拉列表上设置一些属性。您可能需要考虑将所有控件打包到单个用户控件 (.ascx) 中,并将子例程放在代码后面。

为了在应用程序中重用,无需将用户控件存放在 App_Code 文件夹中。只需将用户控件放到您需要该功能的页面上即可。

It sounds like you have a sub-routine that is toggling visibility on multiple controls and setting some properties on a drop down list. You may want to consider packaging all of the controls into a single user control (.ascx) and putting the sub-routine in the code behind.

Housing the user control in the App_Code folder is not necessary for reuse across the application. Just drop the user control onto pages where you want the functionality.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文