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?
Thanks.
tantormediaAsked:
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

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

Open in new window

0

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:
Hi,

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.

Thanks
0
tantormediaAuthor Commented:
carl_tawn,

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?

IJZ,

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.
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

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.
0
tantormediaAuthor Commented:
Thank you for your explanation.
So is it possible to avoid full reload on __doPostBack?
0
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?
0
tantormediaAuthor Commented:
Here it is:
<asp:UpdatePanel ID="upnlMyUpdatePanel" runat="server" UpdateMode="Conditional">
            <Triggers>
                <asp:AsyncPostBackTrigger controlid="btnPrev" eventname="Click" />
                <asp:AsyncPostBackTrigger controlid="btnNext" eventname="Click" />
                <asp:AsyncPostBackTrigger controlid="ddlPageSize" />
                <asp:AsyncPostBackTrigger controlid="btnGo" eventname="Click" />
             
            </Triggers>
            <ContentTemplate>
	            <table class="largegridview" cellspacing="0" rules="all" border="1" id="FrontListGridViewHeader" runat="server" style="height:100%;width:2880px;border-collapse:collapse;table-layout:fixed;">
...
	            </table>    		        
	            <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%" 
                                OnRowDataBound="FrontListGridView_RowDataBound" 
                                OnRowCommand="FrontListGridView_RowCommand"
                                CssClass="largegridview largegridview_td" DataKeyNames="EAN" >        
                        <AlternatingRowStyle CssClass="alternatingrowstyle" />
                        <HeaderStyle CssClass="headerstyle" />
                        
                        <Columns>
 ...           
                        </Columns>
                    </asp:GridView> 
                    
                </div>
                    
                <asp:Label ID="Label1" runat="server" Text="Show rows:" />
                <asp:DropDownList ID="ddlPageSize" runat="server" AutoPostBack="true" 
                    OnSelectedIndexChanged="ddlPageSize_SelectedIndexChanged">
                    <asp:ListItem Value="20" />
                    <asp:ListItem Value="50" />
                    <asp:ListItem Value="100" Selected="True" />
                </asp:DropDownList>
                &nbsp;
                Page 
                <asp:TextBox ID="txtGoToPage" runat="server" AutoPostBack="true" 
                    OnTextChanged="GoToPage_TextChanged" CssClass="gotopage" onchange="JSSetSessionValue('Reload', true);JSSetSessionValue('NewPageNumber', this.value)" />
                of
                <asp:Label ID="lblTotalNumberOfPages" runat="server" />
                &nbsp;
                <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)" />     
                    
            </ContentTemplate>
        </asp:UpdatePanel>

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

Open in new window

0
Carl TawnSystems and Integration DeveloperCommented:
What does JSSetSessionValue() do? It may be interferring.
0
tantormediaAuthor Commented:
It just calls a Page Method that sets a session variable to the specified value.
0
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
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.