Solved

Forcing postback through an update panel

Posted on 2011-03-08
2
317 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now