开发者

Question about moving common routines to the App_Code Class

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 =开发者_JAVA技巧 "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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜