如何从不同选项卡上的页面内部激活不同选项卡并对其进行回发

发布于 2024-10-28 01:39:17 字数 691 浏览 1 评论 0原文

我无法弄清楚一些本来应该很简单的事情,但我在试图弄清楚它时遇到了困难。

我有一个页面(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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

旧人 2024-11-04 01:39:17

好吧,AFAICU,WebTab 控件有 WebTab,每个 webtab 都有页面。试试这个:

  1. 添加控件的自动回发功能。这样调用下一个tab就会自动加载aspx页面。
  2. 如果您不需要回发,那么做一件事,在选项卡控件的单击事件或选项卡更改事件上在查询字符串中添加一些参数。如 page.aspx?tab=1。现在在页面加载事件上,使用下面的逻辑

     1. 检查Request[tab]是否不为空。
          2.使用int.tryparse并获取选项卡号。
          3. 现在在加载选项卡和页面的基础上。 
             并使选项卡处于活动状态。
    

Ok AFAICU, WebTab control has WebTab and each webtab has page. Try this:

  1. Add auto postback feature of the control. So as to call the next tab and it will automatically load the aspx page.
  2. 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

          1. Check if Request[tab] is not null.
          2. use int.tryparse and get the tab number.
          3. Now on the basis of the load the tab and the page. 
             And make the tab active.
    
分分钟 2024-11-04 01:39:17

非常感谢您的回复,但这不是我想要的。

为了解决这个问题,我实际上所做的是在 Default.aspx 页面中创建一个 JavaScript 函数,我可以从 Page1.aspx 调用该函数。

这是 Default.aspx 页面中的函数,它激活了我需要的选项卡,并使用 Page1.aspx 中的 WebDataGrid 中我需要的值填充搜索框。

    <script type="text/javascript">
    function activateTab(rowId, tabId) {
        var tab = $find("WebTab1");
        var ctl;
        if (tabId == 3) {
            ctl = window.frames.document.frames[tabId].window.document.getElementById("WebDialogWindow2_tmpl_txtAddressNumber");
        }
        else if (tabId == 2)
            ctl = window.frames.document.frames[tabId].window.document.getElementById("WebDialogWindow2_tmpl_txtAccount");

        if (ctl != null) {            
            ctl.value = rowId;
            tab.set_selectedIndex(tabId, true, null);
            window.frames.document.frames[tabId].window.DoSearch(rowId);
        } 
    }
</script>

然后,我可以使用以下函数从 Page1.aspx 调用 activateTab() 函数,该函数是从 WebDataGrid 的 DoubleClick 事件调用的(我需要从所选行中获取一个值。)

        function doubleClickRow() {
        var grid = $find("WebDataGrid1");
        //Get the ADDRESS_NUMBER value.
        var rowId = grid.get_behaviors().get_selection().get_selectedRows().getItem(0).get_cell(2).get_value();
        window.parent.activateTab(rowId, 3);
    }

下一步是从 Default.aspx 上的 activateTab() 函数调用 Page2.aspx 上的此 JavaScript 函数,如第一个代码示例所示。

        //Force a Postback
    function DoSearch(id) {
        HideSearch();
        __doPostBack("WebDataGrid1", id);
    }

这实际上完成了我需要的回复,所以这就是我所要做的。如果我想将这 2 个 __doPostBack() 值传递到 Page2.aspx Page_Load 事件中,我必须执行以下操作。然而,就我而言,回发就是我所需要的,因为我已经填充了搜索框。

            //Don't need these right now, but just in case we might I'll leave them in.
        string eventTarget = Page.Request.Params.Get("__EVENTTARGET");
        string eventArgument = Page.Request.Params.Get("__EVENTARGUMENT");
        Search();

对于那些不理解 __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.

    <script type="text/javascript">
    function activateTab(rowId, tabId) {
        var tab = $find("WebTab1");
        var ctl;
        if (tabId == 3) {
            ctl = window.frames.document.frames[tabId].window.document.getElementById("WebDialogWindow2_tmpl_txtAddressNumber");
        }
        else if (tabId == 2)
            ctl = window.frames.document.frames[tabId].window.document.getElementById("WebDialogWindow2_tmpl_txtAccount");

        if (ctl != null) {            
            ctl.value = rowId;
            tab.set_selectedIndex(tabId, true, null);
            window.frames.document.frames[tabId].window.DoSearch(rowId);
        } 
    }
</script>

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.)

        function doubleClickRow() {
        var grid = $find("WebDataGrid1");
        //Get the ADDRESS_NUMBER value.
        var rowId = grid.get_behaviors().get_selection().get_selectedRows().getItem(0).get_cell(2).get_value();
        window.parent.activateTab(rowId, 3);
    }

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.

        //Force a Postback
    function DoSearch(id) {
        HideSearch();
        __doPostBack("WebDataGrid1", id);
    }

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.

            //Don't need these right now, but just in case we might I'll leave them in.
        string eventTarget = Page.Request.Params.Get("__EVENTTARGET");
        string eventArgument = Page.Request.Params.Get("__EVENTARGUMENT");
        Search();

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文