母版页控件正在重置
我在 ASP.NET 应用程序中使用母版页和子页面。 我在母版页上有一个下拉列表和树视图(使用站点地图数据源)。 当我单击任何树视图节点时,页面将重定向到子页面。
问题是,如果在下拉列表中选择任何值并单击树视图节点,则所选值应分配给子页面中的文本框。 这是行不通的。 master page_load()是在child page_load()之后执行的,是因为这个吗?
I am using master page and child pages in asp.net application. I am having a drop down list and treeview (which uses sitemapdatasource) on master page. When I click on any of the treeview node,page is redirected to child page.
The problem is if select any value in the drop down list and click on treeview node, the selected value should be assigned to at ext box in child page. This is not working. master page_load () is executing after child page_load(), is it because of this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您无法直接查看母版页,我假设您有两个使用通用母版页的页面。 我还假设该母版页显示下拉列表和树视图站点地图。
基于此,我认为最常见的情况是您的树视图正在呈现普通的旧 html 链接(即
...
) 。 单击这些按钮后,您的浏览器将对第二个子页面执行获取请求。 默认情况下,第一个子页面中的数据不会传递到第二个子页面。有多种方法可以改变这种行为。 首先,您应该将
AutoPostBack
属性设置为 true,并处理下拉列表中的SelectedIndexChanged
事件。 在这种情况下,您可以保存下拉列表的值,以便稍后恢复。保存该值的最简单方法可能是将其放入会话中。
当子页面加载时,母版页可以通过执行以下操作来恢复此值:
另一种选择是将值添加到树视图中每个 url 的查询字符串中。
Since you can't directly view a master page I'm assuming you have two pages which use a common master page. I am also assuming that this master page displays a drop down list and a treeview sitemap.
Based on this I would think that what is mostly happening is that your treeview is rendering plain old html links (i.e.
<a href='http://stackoverflow.com'>...
). When these are clicked your browser executes a get request for the second child page. By default no data from the first child page is passed to the second.There are various ways to change this behavior. First you should set the
AutoPostBack
property to true and the handleSelectedIndexChanged
event on your dropdownlist. In that event you can save the value of the dropdown so that it can be restored later.The easiest way to save this value is probably to put it in the session.
Your master page can restore this value when the child page loads by doing something like:
Another option would be to add the value to the querystring of each url in the treeview.