关于将通用例程移至 App_Code 类的问题
我有一些想要在页面之间共享的通用代码,并且我一直在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来您有一个子例程可以切换多个控件的可见性并在下拉列表上设置一些属性。您可能需要考虑将所有控件打包到单个用户控件 (.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.