“内容"页面上使用的主控件 [英] Master control used on Content page
问题描述
你好,
我喜欢您关于内部母版页"的文章.现在,我可以隐藏用于菜单的面板.
我的问题是我已经在主数据库上放置了一个下拉列表,当我进行更改时,我希望根据我所在的页面来进行特定的处理.
这也是下拉列表在那里时我在内容页面上拥有的代码.
Hello,
I loved your article about "Inside Master Page". I now can hide a panel that I use for a menu.
My question is that I have placed a dropdownlist on the master and when I make a change, I want specific things to occur depending on the page that I am on.
Here is the code that I use to have on the content page when the dropdownlist was there as well.
Protected Sub ddlPrintGroup_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlPrintGroup.SelectedIndexChanged
On Error GoTo sub_error
Dim strSub As String
strSub = "ddlPrintGroup_SelectedIndexChanged"
''================================================================================
myddlLocs.SelectedIndex = -1
PreviewReport()
''================================================================================
sub_exit:
Exit Sub
sub_error:
If mytxtMsg.Text = "" Then
mytxtMsg.Text = "Error in Sub " & strSub & " - " & Err.Number & " : " & Err.Description
End If
mytxtMsg.Visible = True
End Sub
我在类的顶部添加了一个名为以下内容的变量:
I have added a variable called the following at the top of the class:
Public myddlPrintGroup As DropDownList
在Page_Init中,我有以下内容:
In the Page_Init, I have the following:
myddlPrintGroup = CType(myMaster.FindControl("ddlPrintGroup"), DropDownList)
如何获取子例程ddlPrintGroup_SelectedIndexChanged来查看母版页上的myddlPrintGroup?
谢谢!
Eddi Rae
How do I get the subroutine ddlPrintGroup_SelectedIndexChanged to look at the myddlPrintGroup that is on the master page?
Thanks!
Eddi Rae
推荐答案
我喜欢您关于内部母版页"的文章".
I loved your article about "Inside Master Page".
如果您想与文章作者交谈,文章下方有一个论坛.
使用委托在您编写的每个页面中挂接事件.
If you want to talk to an article author, there''s a forum under the article.
Use a delegate to hook the event up in each page that you write.
myddlPrintGroup = CType(myMaster.FindControl("ddlPrintGroup"),DropDownList)
myddlPrintGroup = CType(myMaster.FindControl("ddlPrintGroup"), DropDownList)
您应该提供一个自定义的基类,而不是像这样的讨厌的代码,该基类强烈地在属性中键入母版,然后可以在其上公开诸如委托和属性之类的东西.
Instead of nasty code like this, you should provide a custom base page class, which strongly types your master page in a property, then you can expose things like delegates and properties on it.
这篇关于“内容"页面上使用的主控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!