Solved

Forcing postback through an update panel

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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 video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

9 Experts available now in Live!

Get 1:1 Help Now