如何从不同选项卡上的页面内部激活不同选项卡并对其进行回发
我无法弄清楚一些本来应该很简单的事情,但我在试图弄清楚它时遇到了困难。
我有一个页面(Default.aspx),其中包含一个 WebTab 控件(Infragistics,但实际上并不重要)。 WebTab 的每个选项卡控件内部都有另一个页面,Page1.aspx、Page2.apx,所以它是这样的:
Default.aspx
WebTab
WebTabControl(0)
Page1.aspx <-- I'm in this codebehind after
calling __doPostBack from JavaScript
as I have a parameter from a WebDataGrid.
WebTabControl(1)
Page2.aspx <-- I want to open this page and pass it a parameter.
我在 Page1.aspx 代码隐藏中进行回发,因为我有一个需要传递到下一页的参数,我想打开第二个选项卡内的 Page2.apx。
基本上,我认为我需要执行以下步骤。 1. 将活动选项卡设置为WebTabControl(1) 2. 给它一个参数,让它做一些事情。
我知道一旦有人告诉我怎么做,我就得开枪自杀了:-) 谢谢!
I'm having trouble figuring out something that should be simple but I'm having trouble trying to figure it out.
I have a Page (Default.aspx) which contaiins a WebTab Control (Infragistics, but shouldn't matter really). Inside each Tab Control of the WebTab is another page, Page1.aspx, Page2.apx, so it's like this:
Default.aspx
WebTab
WebTabControl(0)
Page1.aspx <-- I'm in this codebehind after
calling __doPostBack from JavaScript
as I have a parameter from a WebDataGrid.
WebTabControl(1)
Page2.aspx <-- I want to open this page and pass it a parameter.
I'm in Page1.aspx codebehind doing a postback as I have a parameter that I need to pass to the next page, and I want to open Page2.apx which is inside the 2nd Tab.
Basically, I think I need to do the following steps.
1. Set the Active Tab to WebTabControl(1)
2. Give it the Parameter that I have for it to do something with.
I know I'll have to shoot myself once someone tells how to do it :-)
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,AFAICU,WebTab 控件有 WebTab,每个 webtab 都有页面。试试这个:
如果您不需要回发,那么做一件事,在选项卡控件的单击事件或选项卡更改事件上在查询字符串中添加一些参数。如 page.aspx?tab=1。现在在页面加载事件上,使用下面的逻辑
Ok AFAICU, WebTab control has WebTab and each webtab has page. Try this:
If you do not need Postback then do one thing, on the click event or tab change event of the tab control add some parameter in the query string. Like page.aspx?tab=1. Now on the page load event, use the logic below
非常感谢您的回复,但这不是我想要的。
为了解决这个问题,我实际上所做的是在 Default.aspx 页面中创建一个 JavaScript 函数,我可以从 Page1.aspx 调用该函数。
这是 Default.aspx 页面中的函数,它激活了我需要的选项卡,并使用 Page1.aspx 中的 WebDataGrid 中我需要的值填充搜索框。
然后,我可以使用以下函数从 Page1.aspx 调用 activateTab() 函数,该函数是从 WebDataGrid 的 DoubleClick 事件调用的(我需要从所选行中获取一个值。)
下一步是从 Default.aspx 上的 activateTab() 函数调用 Page2.aspx 上的此 JavaScript 函数,如第一个代码示例所示。
这实际上完成了我需要的回复,所以这就是我所要做的。如果我想将这 2 个 __doPostBack() 值传递到 Page2.aspx Page_Load 事件中,我必须执行以下操作。然而,就我而言,回发就是我所需要的,因为我已经填充了搜索框。
对于那些不理解 __EVENT* 代码最后一部分的人,如果您使用 ScriptManager 是可能的,否则您必须编写自己的参数,我不会在这里讨论。
这就是全部了。我当然在这里学到了一些 JavaScript,所以我希望它对其他人有用。
谢谢
戴夫
Thanks very much for the response, but that's not what I was looking for.
What I actually did to resolve this problem was to create a JavaScript function in the Default.aspx page that I was able to call from Page1.aspx.
This is the function in the Default.aspx Page, which activated the Tab that I needed and populated the search box with the value I needed from the WebDataGrid from Page1.aspx.
I was then able to call the activateTab() function from Page1.aspx with the following function, which is called from the DoubleClick event of the WebDataGrid (I needed to grab a value from the row that was selected.)
The next step was to call this JavaScript function on Page2.aspx from the activateTab() function on Default.aspx as shown in the first code example.
This actually did the post back that I needed so that's all I had to do. If I wanted to pass those 2 __doPostBack() values into the Page2.aspx Page_Load event, I would have to do the following. However in my case the Post back was all I needed as I had already populated the search box.
For those who don't understand the last part with the __EVENT* code, it's possible if you use a ScriptManager, otherwise you have to code your own Parameters, which I won't get into here.
That's all there was to it. I certainly learned some JavaScript along the way here so I hope it's useful for someone else out there.
Thanks
Dave