UpdatePanel question

Dear experts,

I am trying to use a GridView inside of an UpdatePanel. On pressing the Go button, the following is executed among other things:
                javaScript.Append("var userConfirmation = window.confirm('" + confirmMessage.TrimEnd(',', ' ') + "?');\n");
                javaScript.Append("if ( userConfirmation == true )\n");
                javaScript.Append("__doPostBack('UserConfirmationPostBack', userConfirmation);\n");

                Page.ClientScript.RegisterStartupScript(this.GetType(), scriptKey, javaScript.ToString(), true);

But because of the UpdatePanel (I guess), the confirmation never shows up, and the postback does not happen. How can I have a partial postback?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Carl TawnSystems and Integration DeveloperCommented:
Instead of:
Page.ClientScript.RegisterStartupScript(this.GetType(), scriptKey, javaScript.ToString(), true);

Open in new window

ScriptManager.RegisterStartupScript(Page, Page.GetType(), scriptKey, javaScript.ToString(), true);

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:

Make sure confirmation Label is also in same update panel, alternatively add the label in other update panel and use triggers to get message panel to be updated.

tantormediaAuthor Commented:

Thank you for your answer. Everything works now (could you please explain, why?), but now it seems like the whole page is reloaded, not only the GridView in the UpdatePanel. Is it possible to do only a partial update?


The confirmation is not a label control, it is just a javascript confirm(). I don't know how to put it within the UpdatePanel. And it seems like the confirmation window appeared just after replacing Page.ClientScript with ScriptManager.
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

Carl TawnSystems and Integration DeveloperCommented:
Basically the ClientScript object deals with standard pages, whereas the ScriptManager deals specifically with AJAX enabled pages. The callback mechanism for AJAX pages is different to standard pages and the ScriptManager object takes care of handling those differences.
tantormediaAuthor Commented:
Thank you for your explanation.
So is it possible to avoid full reload on __doPostBack?
Carl TawnSystems and Integration DeveloperCommented:
It should be, but it depends on you page setup. Can you post the structure of your page, just the UpdatePanels and the controls that trigger postback will do?
tantormediaAuthor Commented:
Here it is:
<asp:UpdatePanel ID="upnlMyUpdatePanel" runat="server" UpdateMode="Conditional">
                <asp:AsyncPostBackTrigger controlid="btnPrev" eventname="Click" />
                <asp:AsyncPostBackTrigger controlid="btnNext" eventname="Click" />
                <asp:AsyncPostBackTrigger controlid="ddlPageSize" />
                <asp:AsyncPostBackTrigger controlid="btnGo" eventname="Click" />
	            <table class="largegridview" cellspacing="0" rules="all" border="1" id="FrontListGridViewHeader" runat="server" style="height:100%;width:2880px;border-collapse:collapse;table-layout:fixed;">
	            <div style="height:400px; width:2900px; overflow:auto;">
                    <asp:GridView ID="FrontListGridView" runat="server" AllowSorting="False" ShowFooter="False" ShowHeader="false"
                                AllowPaging="True" PageSize="100" DataSourceID="FrontListSqlDataSource" 
                                AutoGenerateColumns="False" Width="2880px" Height="100%" 
                                CssClass="largegridview largegridview_td" DataKeyNames="EAN" >        
                        <AlternatingRowStyle CssClass="alternatingrowstyle" />
                        <HeaderStyle CssClass="headerstyle" />
                <asp:Label ID="Label1" runat="server" Text="Show rows:" />
                <asp:DropDownList ID="ddlPageSize" runat="server" AutoPostBack="true" 
                    <asp:ListItem Value="20" />
                    <asp:ListItem Value="50" />
                    <asp:ListItem Value="100" Selected="True" />
                <asp:TextBox ID="txtGoToPage" runat="server" AutoPostBack="true" 
                    OnTextChanged="GoToPage_TextChanged" CssClass="gotopage" onchange="JSSetSessionValue('Reload', true);JSSetSessionValue('NewPageNumber', this.value)" />
                <asp:Label ID="lblTotalNumberOfPages" runat="server" />
                <asp:Button ID="btnPrev" runat="server" CommandName="Page" Enabled="false" 
                    ToolTip="Previous Page" CssClass="previous" OnClick="btnPrev_Click" OnClientClick="JSSetSessionValue('Reload', true)" />
                <asp:Button ID="btnNext" runat="server" CommandName="Page" ToolTip="Next Page" 
                    CssClass="next" OnClick="btnNext_Click" OnClientClick="JSSetSessionValue('Reload', true)" />     

    <asp:Button ID="btnGo" runat="server" Text="Go" 
        Width="30px" onclick="btnGo_Click" OnClientClick="JSSetSessionValue('Reload', true)" />

Open in new window

Carl TawnSystems and Integration DeveloperCommented:
What does JSSetSessionValue() do? It may be interferring.
tantormediaAuthor Commented:
It just calls a Page Method that sets a session variable to the specified value.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.