Solved

Forcing postback through an update panel

Posted on 2011-03-08
2
323 Views
Last Modified: 2012-05-11
I have a web form (asp.net front, c# back) which has two pages. The first page is a dashboard of sorts which provides the user with a queue of records drawn from the database. I have a "next" button which automatically goes to the next record in the queue, and launches a new window with certain variables in it to configure the second page.

Problem is, I recently modified the dashboard page to use update panels, and partial postbacks, so that the page isnt reloading everytime someone changes a setting or what have you.

So the script that actually launches the new window is triggered via javascript on the loading of the page window. Since this page is now in an update panel, I believe when the next button is hit, the next record is "loaded" and the URL for the new window launch is available, but the javascript that launches the windows isnt firing, because technically the page isnt reloading.

Can someone help me figure out a solution to this?

Here is the javascript at the beginning of the page:

function window_onload() {

        if (window.name != "WTMAIN") {
            window.open("main.aspx", "WTMAIN", "", false);
            window.open("", "_self", "", false);
            window.opener = top;
            window.close();
        }
        window.top;
        window.moveTo(0, 0);
        window.resizeTo(screen.width, screen.height);

        if (form1["HFUrl"].value.length > 0) {
            window.open(form1["HFUrl"].value, "CRM", "", false);
            form1["HFUrl"].value = "";
        }
    }

Once the next button is pushed, the "HFUrl" (simply a hidden field which tells the app WHICH page to launch) is populated with the page and the variables needed. Before the update panel was put in, it would reload the page and launch the window.

One way I KNOW would fix this, would be to remove the overall update panel on the form, and replace it with separate update panels around all the different elements that need them, and this would leave certain other elements that DONT need them (like the next button) automatically posting back the page like they used to.... I'm trying to avoid doing this if possible.

Thanks!
0
Comment
Question by:nuvium
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Expert Comment

by:kolakanuru1
ID: 35073825
Did you try calling window_onload function in the clientclick event of the next button?
0
 
LVL 15

Accepted Solution

by:
rajeeshmca earned 500 total points
ID: 35078989
Hi,

U could instead use triggers with update panel....

<asp:UpdatePanel ID="updatePnl" runat="server" UpdateMode=Conditional>
            <ContentTemplate>
             
                <asp:GridView ID="gridViewPersons" runat="server"
                AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333"
                GridLines="None" Width="460px">
                </asp:GridView>
               <asp:button ID ="triggerbutton" runat="server" Text="Trigger" />
                   
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="triggerbutton" />
            </Triggers>

        </asp:UpdatePanel>
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question