Solved

Forcing postback through an update panel

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

710 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