CrossPost 数据访问
我在页面上有一个搜索表单,可以回发到自身并显示结果,一切正常。我现在需要在网站主页上放置相同的搜索表单。这需要发回搜索表单并运行 findResults 代码。使用主页表单的提交按钮上的 PostBackURL 参数,我可以正常点击搜索页面。但是,当在搜索页面的 Page_Load 部分使用以下代码时,我遇到了无法从发布页面访问数据的问题,因为我在以“yearList.SelectedValue ....”开头的行上收到以下错误消息:“'Site._default1.Protected WithEventsyearList As System.Web.UI.WebControls.DropDownList'在此上下文中无法访问,因为它是'受保护的'”。
'################################# '# Handle form post from Home page '################################# Dim crossPostBackPage As Site._default1 If Not (Page.PreviousPage Is Nothing) Then If Not (Page.IsCrossPagePostBack) Then If (Page.PreviousPage.IsValid) Then crossPostBackPage = CType(PreviousPage, Site._default1) yearList.SelectedValue = crossPostBackPage.yearList.SelectedValue getAvailability() End If End If End If
由于我没有声明yearList Protected,我不知道在哪里更改它或如何更改。
任何建议将不胜感激,
克雷格
I have a search form on a page that posts back to itself and shows the results, all works fine. I now have a requirement to put the same search form on the site home page. This needs to post back to the search form and run the findResults code. Using the PostBackURL parameter on the home page form's submit button I can hit the search page ok. However, when using the following code in the Page_Load section of the search page I hit the problem of not being able to access data from the posting page as I get the following error message on the line starting "yearList.SelectedValue....": "'Site._default1.Protected WithEvents yearList As System.Web.UI.WebControls.DropDownList' is not accessible in this context because it is 'Protected'".
'################################# '# Handle form post from Home page '################################# Dim crossPostBackPage As Site._default1 If Not (Page.PreviousPage Is Nothing) Then If Not (Page.IsCrossPagePostBack) Then If (Page.PreviousPage.IsValid) Then crossPostBackPage = CType(PreviousPage, Site._default1) yearList.SelectedValue = crossPostBackPage.yearList.SelectedValue getAvailability() End If End If End If
As I didn't declare yearList Protected, I don't know where to change it or how to.
Any advice would be appreciated,
Craig
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
参考: http://msdn.microsoft.com/en-us/library/ ms178139.aspx
注意:vb 是我测试过的 C# 代码的快速翻译,所以不要按字面意思理解。
reference: http://msdn.microsoft.com/en-us/library/ms178139.aspx
note: the vb is a quick off the top of my head translation of my tested c# code, so don't take it literally.