I have a gridview that has many columns within an UpdatePanel, 2 of those columns that are populated with buttons. There is a "Update" button outside of the gridview. When the user clicks "Update", there is a UpdateProgress div that shows up, which is expected. However, when the buttons in the gridview are clicked, it also shows up, which is not what I am intending. How can I exclude these buttons from the UpdateProgress if the gridview itself is in the UpdatePanel? I've tried ChildrenAsTriggers=False and UpdateMode=Conditional but doesn't help. See code being used below.
<asp:UpdateProgress id="UpdateProgress" runat="server">
<ProgressTemplate>
<div style="position: fixed; text-align: center; height: 100%; width: 100%; top: 0; right: 0; left: 0; z-index: 9999999; background-color: #000000; opacity: 0.7;">
<asp:Image ID="imgUpdateProgress" runat="server" ImageUrl="~/images/ajax-loader.gif" AlternateText="Updating PO, please wait ..." ToolTip="Updating PO, please wait ..." style="padding: 10px;position:fixed;top:45%;left:50%;" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="UpdateButton" EventName="Click"/>
</Triggers>
<ContentTemplate>
<!-- Gridview is here -->
</ContentTemplate>
</asp:UpdatePanel>
Example of what's in the gridview:
<asp:TemplateField HeaderText="Button Column One">
<HeaderStyle Width="70px" />
<ItemStyle Wrap="False" HorizontalAlign="Center" Width="70px" />
<ItemTemplate>
<asp:Button ID="btnG" runat="server" OnCommand="btnG_Command" Text="View"/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="False" HeaderText="Drug Details">
<ItemTemplate>
<asp:Button ID="btnA" runat="server" OnCommand="btnA_Command" Text="View" />
</ItemTemplate>
<HeaderStyle Width="60px" HorizontalAlign="Center" />
<ItemStyle Width="60px" HorizontalAlign="Center" />
</asp:TemplateField>
Put your Gridview in a separate update panel and specify AssociatedUpdatePanelID field for UpdateProgress control.
<asp:UpdateProgress id="UpdateProgress" runat="server" AssociatedUpdatePanelID="UpdatePanelForButton">
<ProgressTemplate>
<div style="position: fixed; text-align: center; height: 100%; width: 100%; top: 0; right: 0; left: 0; z-index: 9999999; background-color: #000000; opacity: 0.7;">
<asp:Image ID="imgUpdateProgress" runat="server" ImageUrl="~/images/ajax-loader.gif" AlternateText="Updating PO, please wait ..." ToolTip="Updating PO, please wait ..." style="padding: 10px;position:fixed;top:45%;left:50%;" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanelForButton" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="UpdateButton" EventName="Click"/>
</Triggers>
<ContentTemplate>
<!--Button goes here-->
</ContentTemplate>
</asp:UpdatePanel>
Related
Style of dropdown in css changes when the page loads. i have tried a number of ways to solve the problem. also i am not able to find dropdownlist id in Update Trigger... any suggestions to help me out...i am stuck at this..thank you in advance...
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView runat="server" ID="gvDetails" AutoGenerateColumns="False" ShowHeaderWhenEmpty="True"
ForeColor="#333333" GridLines="None" ShowFooter="True" Width="855px">
<Columns>
<asp:BoundField DataField="SNo" HeaderText="S.N." ReadOnly="true" />
<asp:TemplateField Items Detail"
ControlStyle-Width="150px" ItemStyle-HorizontalAlign="center">
<ItemTemplate>
<asp:DropDownList ID="ddlItem" runat="server" ForeColor="Black" Height="35px" CssClass="chzn-select"
Style="width: 210px;" Font-Bold="false" AutoPostBack="true" OnSelectedIndexChanged="ddlItem_SelectedIndexChanged">
</asp:DropDownList>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblTotalText" runat="server" Text="Total :"></asp:Label>
</FooterTemplate>
<ControlStyle Width="150px" />
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="" ControlStyle-Width="0px" Visible="true">
<ItemTemplate>
<asp:TextBox ID="txtMRP" runat="server" Enabled="false" Visible="true" BorderStyle="None"
BackColor="White" />
</ItemTemplate>
<ControlStyle Width="0px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="" ControlStyle-Width="0px" Visible="true">
<ItemTemplate>
<asp:TextBox ID="txtAmount" runat="server" Enabled="false" Visible="true" BorderStyle="None"
BackColor="White" />
</ItemTemplate>
<ControlStyle Width="0px" />
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlItem" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
<br />
<div style="margin-left: 50px; margin-top: 10px">
</div>
<br />
<asp:Button ID="btnAddSalesOrder" runat="server" Text="Send Inquiry" OnClick="btnAddSalesOrder_Click"
Style="margin-left: 30px; color: White; background-color: #088FCA;" OnClientClick="myClosure();"
class="btn btn-info" />
<asp:Button ID="btnPlaceOrder" runat="server" OnClick="btnPlaceOrder_Click" Text="Place Order"
Style="margin-left: 30px; color: White; background-color: #088FCA;" OnClientClick="myClosure();"
class="btn btn-info" />
<asp:UpdateProgress ID="UpdtProgress" DisplayAfter="1" runat="server" EnableViewState="False">
<ProgressTemplate>
<div style="top: 0px; height: 120%; background-color: White; opacity: 0.75; filter: alpha(opacity=75);
vertical-align: middle; left: 0px; z-index: 999999; width: 120%; position: absolute;
text-align: center;">
<img src="Images/loader.gif">
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</div>
<script type="text/javascript">
$('.chzn-select').select2({
no_results_text: 'Oops, nothing found!',
allowClear: true,
maximumSelectionSize: 1,
width: '130px;'
});
I have a aspx page with a ajax modalpopup control in it. I need to update the contents inside an updatepanel on the page(not inside modalpopup) when I do a button click inside the modalpopup.
So I can display the changes inside the updatepanel without a full page refresh. I already tried using the UpdatePanel.Update() method inside the code behind of the button click event. But it does nothing.
What I'm doing right now is make a full page refresh inside the button click event.
there anyway that I can update the update panel to display the changes?
Update: Here is the code snippet in the related aspx page.
<div style="width: 400px; height: 200px; float: right;">
<br />
<asp:UpdatePanel ID="UpdatePanel5" runat="server" UpdateModel="Conditional">
<ContentTemplate>
<asp:Label ID="lblDate" runat="server"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnGetSelectedDate" />
</Triggers>
</asp:UpdatePanel>
</div>
<ajaxToolkit:ModalPopupExtender ID="mpeUpcomingDaysOff" runat="server" PopupControlID="panelUpcomingDaysOff" BackgroundCssClass="modalBackground" DropShadow="true" Enabled="True" TargetControlID="btnChangeUpcomingDaysoff" OkControlID="btnGetSelectedDate" CancelControlID="btnUpcomingDaysOffCancel" OnOkScript="window.top.location.reload();">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="panelUpcomingDaysOff" runat="server" Height="400" Width="700" BackColor="White" Style="border-radius: 5px">
<div style="height: 50px; width: 700px; padding-left: 100px; font-family: Verdana; padding-top: 5px">
<div>
<span style="font-weight: bold">Upcoming Daysoff for
<asp:Label ID="lblProviderNameDaysOff" runat="server"></asp:Label></span><br />
<span style="font-size: 12px">Select vacation and any other days when this service provider will not be available for online appointments.</span>
</div>
<div style="height: 300px; padding-left: 150px">
<asp:UpdatePanel ID="UpdatePanel4" runat="server">
<ContentTemplate>
<asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="Black"
Font-Names="Verdana" Font-Size="9pt" ForeColor="Black" Height="250px" OnPreRender="Calendar1_PreRender" Width="330px"
OnSelectionChanged="Calendar1_SelectionChanged" OnLoad="Calendar1_Load" BorderStyle="Solid" CellSpacing="1" NextPrevFormat="ShortMonth">
<DayHeaderStyle Font-Bold="True"
Height="8pt" Font-Size="8pt" ForeColor="#333333" />
<DayStyle BackColor="#CCCCCC"></DayStyle>
<NextPrevStyle Font-Size="8pt" ForeColor="White" Font-Bold="True" />
<OtherMonthDayStyle ForeColor="#999999" />
<SelectedDayStyle BackColor="#333399" ForeColor="White" />
<TitleStyle BackColor="#333399" Font-Bold="True"
Font-Size="12pt" ForeColor="White" BorderStyle="Solid" Height="12pt" />
<TodayDayStyle BackColor="#999999" ForeColor="White" />
</asp:Calendar>
<br />
<asp:Button ID="btnGetSelectedDate" runat="server" Text="OK" OnClick="btnGetSelectedDate_Click" />
<asp:Button ID="btnUpcomingDaysOffCancel" runat="server" Text="Cancel" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
In your update panel you wish to update you need to declare the button of your modal div as async postback trigger.
<asp:UpdatePanel ID="upPanel" runat="server" UpdateModel="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Id_Of_Button_In_ModalDiv" />
</Triggers>
<ContentTemplate>
....
</ContentTemplate>
</asp:UpdatePanel>
Keep in mind though that your modal div should not be part of the update panel. If it is, it will disappear after call back as everything within the ContentTemplate will be replaced with content from server.
I have a grid view and inside it i used an update panel and because of using a file upload in it, I use trigger method. What i want is to have a nice update progress as an user hit a button in the grid view. I need to make the page disable and showing the downloading animation. like the below picture. However instead of the dialog message, a loading
animation must be appear. Is it solvable?
And here is my cod that i used, but it wasn't work:
<ContentTemplate>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" onrowdatabound="GridView1_RowDataBound"
DataKeyNames="ID,ArticleID,UserName" DataSourceID="SqlDataSource1"
GridLines="Vertical" AllowPaging="True" PageSize="5" OnRowUpdating="GridView1_RowUpdating">
<Columns>
<asp:TemplateField>
<ItemTemplate>
.......some stuffs
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="Gridview1" />
</Triggers>
</asp:UpdatePanel>
I also used this:
.Background
{
position: relative;
left: 0;
top: 0;
z-index: 10;
width: 100%;
height: 100%;
filter: alpha(opacity=40)
}
And this
<asp:UpdateProgress ID="UpdateProgress4" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<DIV id="IMGDIV" align="center" valign="middle" runat="server" style=" position: relative; visibility:visible; vertical-align:middle; border-style :inset;border-color:black;background-color:white;z-index:40; top:45%;">
<img src="../images/NewLoader.gif" /><br />
<%-- <input type="button" onclick="CancelPostBack()" value="Cancel" />--%>
</DIV>
</ProgressTemplate>
</asp:UpdateProgress>
I think you have to use
<asp:AsyncPostBackTrigger>
not
<asp:PostBackTrigger >
<asp:UpdateProgress> will work only for Async calls.
<asp:UpdatePanel ID="Upnl1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table width="100%"><tr>
<td align="center" colspan="3">
<asp:Button ID="btnShowReport" runat="server" CssClass="ButtonClassLong" SkinID="LargeButton"
Text="Show Report" OnClick="btnShowReport_Click" TabIndex="15" />
<asp:Button ID="btnClear" runat="server" CssClass="ButtonClass" Text="Clear" OnClick="btn_Click"
TabIndex="16" />
<asp:Button ID="btnClose" runat="server" CssClass="ButtonClass" OnClick="btnClose_Click"
Text="Close" CausesValidation="False" TabIndex="17" />
<asp:CheckBox ID="ChkPrint" Text="Print View" runat="server" TabIndex="14" />
</td>
</tr>
</table></ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnShowReport" />
</Triggers></asp:UpdatePanel><asp:UpdateProgress ID="UpdateProgress" runat="server">
<ProgressTemplate>
<asp:Image ID="Image1" ImageUrl="~/App_Themes/RIBO/Images/Progress.gif" AlternateText="Processing"
runat="server" />
</ProgressTemplate>
</asp:UpdateProgress>
This is my coding , My issue is when i click the clear button the update progress working well, when i click btnShowReport it wont work.
how to show the update progress for button click event which is in inside the trigger property.
Problem is AssociatedUpdatePanelID . You havn't set Associateid of your 'UpdateProgress`
set it on UpdateProgress
<asp:UpdateProgress ID="UpdateProgress" runat="server" AssociatedUpdatePanelID="Upnl1">
As per MSDN
The UpdateProgress control renders a element that is displayed or hidden
depending on whether an associated UpdatePanel control has caused an
asynchronous postback. For initial page rendering and for synchronous
postbacks, the UpdateProgress control is not displayed.
EDIT:
Reason is <asp:PostBackTrigger ControlID="btnShowReport" />
Which will cause a full page postback. You should change your Trigger to
<asp:AsyncPostBackTrigger ControlID="btnShowReport" />
and it will do the job for you...If you could have read the quoted statement you would have able to solve it by yourself too...
This is working for me, I hope this will helpful for some
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Show Loading Image while uploading images using updatepanel</title>
<style type="text/css">
.overlay
{
position: fixed;
z-index: 999;
height: 100%;
width: 100%;
top: 0;
background-color: Black;
filter: alpha(opacity=60);
opacity: 0.6;
-moz-opacity: 0.8;
}
</style>
<script type="text/javascript">
function showProgress() {
var updateProgress = $get("<%= UpdateProgress.ClientID %>");
updateProgress.style.display = "block";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="scriptmanager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel runat="server" ID="updatepanel1" UpdateMode="Conditional">
<ContentTemplate>
<div style="align:center; margin-left:350px; margin-top:200px">
<asp:FileUpload ID="uploadfiles1" runat="server" />
<asp:Button ID="btnUpload" Text="Upload" runat="server" onclick="btnUpload_Click" OnClientClick="showProgress()" /><br />
<asp:Label ID="lblMsg" runat="server"/>
</div>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnUpload" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress" runat="server" AssociatedUpdatePanelID="updatepanel1">
<ProgressTemplate>
<div class="overlay">
<div style=" z-index: 1000; margin-left: 350px;margin-top:200px;opacity: 1;-moz-opacity: 1;">
<img alt="" src="loading.gif" />
</div>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</form>
</body>
</html>
I have an Ajax panel first panel inside another panel second panel and an updateProgress linked to the first panel
With this I have two problems:
The updateProgress show the progress image when the second panel updates but not when the first panel updates
To update the 2nd panel I have to press the button inside the second panel twice
<asp:UpdateProgress ID="UProc_TabContainer" runat="server" AssociatedUpdatePanelID="UP_FirstPanel"
DisplayAfter="1">
<ProgressTemplate>
<div id="dvProgress" runat="server" style="position: absolute; top: 300px; left: 450px;
text-align: center;">
<asp:Image ID="wait" runat="server" ImageUrl="~/Images/wait3.gif" Height="120px"
Width="128px" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UP_FirstPanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<script language="javascript" type="text/javascript">
function divexpandcollapse(divname) {
var div = document.getElementById(divname);
var img = document.getElementById('img' + divname);
if (div.style.display == "none") {
div.style.display = "block"; img.src = "Images/Icons/minus.jpg";
} else { div.style.display = "none"; img.src = "Images/Icons/plus.jpg"; }
}</script>
<asp:DropDownList ID="DateSelection" runat="server" AutoPostBack="True" Height="21px"
Width="134px">
</asp:DropDownList>
<asp:GridView ID="GV_SL" runat="server" OnRowDataBound="gvUserInfo_RowDataBound"
OnRowCommand="GV_SL_RowCommand" AutoGenerateColumns="false" DataSourceID="SQL_Weekly">
<Columns>
<asp:TemplateField ItemStyle-Width="50px">
<ItemTemplate>
<a href="JavaScript:divexpandcollapse('div<%# Eval("name") %>');">
<img id="imgdiv<%# Eval("name") %>" width="15px" border="0" src="Images/Icons/plus.jpg" /></a></ItemTemplate>
<ItemStyle Width="40px" />
</asp:TemplateField>
<asp:BoundField DataField="name" HeaderText="Group" SortExpression="name" />
<asp:BoundField DataField="ASL" HeaderText="SL% Act" ReadOnly="True" SortExpression="ASL" />
<asp:TemplateField>
<ItemTemplate>
<tr>
<td colspan="100%">
<div id="div<%# Eval("name") %>" style="display: none; position: relative; left: 15px;
overflow: auto">
<asp:GridView ID="gvChildGrid" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Metric" HeaderText=" " HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="Actual" HeaderText="Actual" HeaderStyle-HorizontalAlign="Left" />
</Columns>
</asp:GridView>
<br />
<asp:UpdatePanel ID="UP_SecondPanel" runat="server" UpdateMode="Always">
<ContentTemplate>
<%-- --%>
<asp:TextBox ID="TB_Comments" runat="server" Text="Example: Text will be entered here"
TextMode="MultiLine" Rows="4" Width="510px"></asp:TextBox>
<asp:Button ID="B_Save" runat="server" CommandName="AddText" CommandArgument="<%# CType(Container,GridViewRow).RowIndex %>"
Text="Save Changes" />
</ContentTemplate>
</asp:UpdatePanel>
<%-- --%>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DateSelection" EventName="SelectedIndexChanged" />
</Triggers>
Any ideas on what I'm doing wrong?
Thanks
I have resolved the 1st problem presented by removing AssociatedUpdatePanelID="UP_FirstPanel" from the UpdateProgress. I hope it helps someone
I've created a separate posting with further detail and simplified code for the second problem (Nested Ajax UpdatePanel in Gridview needs button control to be clicked twice)