Continuous postback - c#

I can't figure out why my page keeps on refreshing, then I put a breakpoint on my Page_Load on aspx page. It keeps on refreshing and loading the Page_Load without me doing anything.
I have some textboxes that has AutoPostBack="True" for TextChange event. Do you guys think that is the problem? Do you guys have any idea why it keeps on doing POST?
Thank you, guys.
These are some of the code.
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="VesselSchedule.aspx.cs" Inherits="VesselHeader.VesselSchedule" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Panel runat="server" DefaultButton="btnVesselCode">
<label class="col-sm-4 control-label">Vessel Code</label>
<div class="col-sm-4">
<asp:TextBox ID="txtVesselCode" runat="server" class="form-control pull-left" placeholder="Vessel Code" onkeypress="return EnterEvent(event)" AutoPostBack="True" OnTextChanged="txtVesselCode_TextChanged" />
<asp:Label ID="lblDescription" runat="server" Text="" ForeColor="blue" Visible="true"></asp:Label>
<asp:Button ID="btnVesselCode" runat="server" Text="Button" visible="false" OnClick="btnVesselCode_Click"/>
</div>
</asp:Panel>
<div class="col-sm-4">
<div class="input-group date">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<asp:TextBox ID="txtPublishedETADate" runat="server" ClientIDMode="Static" class="form-control" OnTextChanged="txtPublishedETADate_TextChanged" AutoPostBack="True"/>
</div>
</div>

Any kind of PostBack will fire the Page_Load event.
To not run the entire code in Page_Load on each post back you need to wrap your code inside a check. A simple if condition will do it for you.
if (!Page.IsPostBack)
{
//code to execute on fresh page load only.
}

Related

OnCommand is not getting triggered and the debugger is not moving to Code Behind in Asp.net

<div class="dt_content">
<asp:UpdatePanel runat="server" ID="AlertUpdatePanel">
<ContentTemplate>
<UserControl:ApplicationAlert runat="server" ID="ApplicationAlert" />
<UserControl:ApplicationAlert runat="server" ID="PersonalEssayAlert" Visible="false" />
<boas:KeyDates ID="KeyDates" runat="server" Visible="false" />
</ContentTemplate>
</asp:UpdatePanel>
<boas:OtherDocs ID="OtherDocs" runat="server" />
<input type="hidden" runat="server" id="AppDetailsHidden" />
<% var dummy = 0; %>
<% if (IsRep || IsAdmin)
{ %>
<%=ResourceUtility.GetThemeResource("Copy", "Instructions_DocumentTracker_RepAdmin")%>
<% }
else
{ %>
<%=ResourceUtility.GetThemeResource("Copy", "Instructions_DocumentTracker")%>
<% } %>
<!-- Accordian Menu -->
<asp:Repeater ID="DocumentListingRepeater" runat="server" OnItemCreated="DocumentListingRepeater_ItemCreated">
<ItemTemplate>
<ul class="CollapsiblePanelGroup">
<li id="SectionLI" runat="server">
<div>
<ul>
<li class="category">
<h3>
<asp:LinkButton ID="OpenDocumentsLinkButton" runat="server" OnClientClick='<%#"return ToggleDocTrackerPanel(" + Convert.ToChar(39) + "cat" + (((RepeaterItem)Container).ItemIndex).ToString() + Convert.ToChar(39) + ")" %>'
OnCommand="OpenDocumentsLinkButton_Command" CommandArgument='<%#DataBinder.Eval(Container.DataItem,"DocumentCategoryID") %>'><img id="toggle<%#(((RepeaterItem)Container).ItemIndex).ToString()%>" alt="" class="toggle" src="../Images/plus.png" /></asp:LinkButton><a
href='Details.aspx?section=<%# DataBinder.Eval(Container.DataItem, "DocumentCategoryID")%>'><%# DataBinder.Eval(Container.DataItem, "DocumentCategoryDescription")%></a></h3>
</li>
<li id="StatusLI" runat="server">
<h3>
<asp:Literal ID="StatusLiteral" runat="server" /></h3>
</li>
</ul>
</div>
<div id="cat<%#(((RepeaterItem)Container).ItemIndex).ToString()%>" class="CollapsiblePanelContent">
<asp:UpdatePanel ID="DocumentTrac" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:PlaceHolder ID="DocumentTrackerPlaceHolder" runat="server">
<div style="text-align: center">
Loading
<br />
<img runat="server" alt="Please wait." src="~/images/loading2.gif" />
</div>
</asp:PlaceHolder>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="OpenDocumentsLinkButton" />
</Triggers>
</asp:UpdatePanel>
</div>
</li>
</ul>
</ItemTemplate>
</asp:Repeater>
<div style="text-align: center;" runat="server" id="applicationRequirementsPanel">
<a runat="server" id="modalButton">
<asp:Image ID="Image1" runat="server" SkinID="img_appReq" /></a>
</div>
<script type="text/javascript">
ToggleDocTrackerPanel();
</script>
</div>
Hi there!
The code snippet I shared, updates the content inside the content panel.
So we have different user roles, and when running the application as a normal user the OnCommand event gets triggered accordingly, gets all the content from the backend, and updates the 'Please Wait' text with the received content inside the Update Panel, but when I try to log in as Admin the same exact piece of code runs but the OnCommand event does not get triggered.
I tried adding the even name but that does not work.
During the page load I can see the data is getting bounded properly(as it is working fine when logged in a normal user).
Being a backend developer I am not that much familiar with this frontend technology, So little help or explanation would be appreciated. Thanks!

How to retain Textbox values after a Postback?

I have few Textbox, FileUpload and button controls within the same page. I had tried enabling the EnableViewState to True but it is still not working. The Textbox will lose its value when clicking the button to upload attachments. May I know what's wrong here, should I use ViewState to retain the values of the textboxes?
<div class="form-row">
<div class="form-group col-md-6" >
<asp:Label ID="lblConfiguration" runat="server" Text="Configuration*"></asp:Label>
<asp:TextBox ID="txtConfiguration" runat="server" type="text" class="form-control" EnableViewState="true" ViewStateMode="Enabled" ></asp:TextBox>
</div>
<div class="form-group col-md-12">
<div class="col-md-6">
<asp:FileUpload ID="fuUpload" runat="server" CssClass="nv-file-select uploader" multiple="true" />
<br />
<asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="btnUpload_Click" CssClass="btn btn-secondary" />
</div>
</div>
Possible reasons
1) You have disable the Viewstate on full page - Check on top of aspx page if its enable or not
<%# Control Language="C#" AutoEventWireup="true" CodeFile="FileName.ascx.cs" EnableViewState="true" %>
2) At some point on code behind you change the value on post back - so check to not change it by adding this check
if (!Page.IsPostBack)
{
TextBox.Text = "";
}
3) For some reason after your post back you do redirect on same page.
4) For some reason you do not make post back, but reload

Open a ModalPopupExtender from checked radiobutton in a datalist

I have a Datalist with binddata from code behind and I'm trying to add an ajax modalpopupextender to each item. This modalpopup needs to open the right panel with the problem that the target control id it's always the same button in the end of the page.
I am getting the radiobutton selected but i can't open the modalpopup that is equivalent to it. It always opens the first panel.
Can anyone help me? Is this even possible?
C#
protected void btnValidateGift_Click(object sender, EventArgs e)
{
if (Request.Form["gift"] != null)
{
}
}
aspx
<asp:DataList ID="datalistReward" runat="server" RepeatDirection="Vertical" RepeatColumns="3" CssClass="datalistGift">
<ItemTemplate>
<div class="giftDiv">
<div class="giftTitle">
<%# DataBinder.Eval(Container.DataItem, "name") %>
</div>
<div>
<img width="60%" src="img/brindes/<%# DataBinder.Eval(Container.DataItem, "img") %>.png" />
</div>
<div id="divRadioBtnGift" runat="server" style="width: 10%; margin: auto;">
<input type='radio' id='radioBtnGift_<%# DataBinder.Eval(Container.DataItem, "value") %>'
name='gift' value='<%# DataBinder.Eval(Container.DataItem, "id") %>' />
</div>
</div>
<asp:ModalPopupExtender ID="ModalPopUpReward" BehaviorID="modalBehaviorPopupReward" runat="server" PopupControlID="panelSelectReward"
CancelControlID="btnCloseReward" BackgroundCssClass="modalBackground" TargetControlID="btnValidateGift" />
<asp:Panel ID="panelSelectReward" runat="server" CssClass="modalPopup" align="center" Style="display: none">
<div style="background-color: aqua; border: 1px solid red;">
<img width="60%" src="img/brindes/<%# DataBinder.Eval(Container.DataItem, "img") %>.png" />
<asp:ImageButton ID="btnCloseReward" runat="server" Text="Close" OnClientClick="CloseModalPopUp()" />
</div>
</asp:Panel>
</ItemTemplate>
</asp:DataList>
<asp:Button ID="btnValidateGift" Text="Validar >" runat="server" CssClass="divButton" OnClick="btnValidateGift_Click" />
Edit1: I've tried to add the a custom string to the panel id like this <%# DataBinder.Eval(Container.DataItem, "id") %> . But this doesn't even compile. Any chance of making this work?
You use server-side OnClick event to show the popup. It just shows the first (or last) data evaluated during page render.
To change ModalPopup's content you need to use OnClientClick event + asynchronous call to fill the popup with the data you need.
Here is the example of using client events with ModalPopup.

Button event doesn't fire inside Update panel for FileUpload

I have a asp.net web form Page which uses master page also.
This is a simple page which displays some text and has a form, this page also allows user to upload resume in .doc, .docx & pdf format.
Problem with this code is that i am not able to trigger
for some reason <asp:Button ID="btnUploadCV" runat="server" Text="Upload" CssClass="btnUpload" onclick="btnUploadCV_Click"/>
<%# Page Title="" Language="C#" MasterPageFile="~/en/SiteMasterPage.master" AutoEventWireup="true" CodeFile="career.aspx.cs" Inherits="career" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"></asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<!-- Content Page-->
<!-- page content wrapper -->
<div id="page-content-area" class="page-content-area">
<div id="pg-left-bar" class="pg-left-bar">
<div class="page-title">
<h5><asp:Label ID="lblPageTitle" CssClass="page-title-lbl" runat="server" Text="Introduction"></asp:Label></h5>
</div>
<div class="page-text">
<asp:Label ID="lblPageContents" runat="server" Text=""></asp:Label>
</div>
<div class="career-form-wrapper">
<!-- UpdatePanel -->
<asp:UpdatePanel ID="updPnlArticles" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="pnlCareerForm" runat="server">
<div class="row-form">
<div class="row-lbl-wrapper"> <span class="row-req">*</span>
<asp:Label ID="lblFirstName" runat="server" CssClass="row-label" Text="First Name:"></asp:Label>
</div>
<asp:TextBox ID="txtFirstName" runat="server" CssClass="row-input"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfFN" runat="server" ValidationGroup="Careers" ErrorMessage="*" CssClass="row-validate" ControlToValidate="txtFirstName"></asp:RequiredFieldValidator>
</div>
<div class="row-form">
<div class="row-lbl-wrapper"> <span class="row-req">*</span>
<asp:Label ID="lblFamilyName" runat="server" CssClass="row-label" Text="Family Name:"></asp:Label>
</div>
<asp:TextBox ID="txtFamilyName" runat="server" CssClass="row-input"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfLN" runat="server" ValidationGroup="Careers" ErrorMessage="*" CssClass="row-validate" ControlToValidate="txtFamilyName"></asp:RequiredFieldValidator>
</div>
<div class="row-form">
<div class="row-lbl-wrapper"> <span class="row-req">*</span>
<asp:Label ID="lblEmail" runat="server" CssClass="row-label" Text="Email:"></asp:Label>
</div>
<asp:TextBox ID="txtEmail" runat="server" CssClass="row-input"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvEmail" runat="server" ValidationGroup="Careers" ErrorMessage="*" CssClass="row-validate" ControlToValidate="txtEmail"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="revEmail" runat="server" ErrorMessage="*" CssClass="row-validate" ControlToValidate="txtEmail" ValidationExpression="\w+([-+.']\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*" ValidationGroup="Careers"></asp:RegularExpressionValidator>
</div>
<div class="row-form">
<div class="row-lbl-wrapper">
<asp:Label ID="lblPhone" runat="server" CssClass="row-label" Text="Phone Number:"></asp:Label>
</div>
<asp:TextBox ID="txtPhone" runat="server" CssClass="row-phone" Text=""></asp:TextBox>
<asp:RegularExpressionValidator ID="revPhone" runat="server" ErrorMessage="*" ValidationGroup="Careers" ControlToValidate="txtPhone" ValidationExpression="^([\+]?[0-9]{1,3}[\s.-][0-9]{1,12})([\s.-]?[0-9]{1,4}?)$"></asp:RegularExpressionValidator>
<div class="tooltip tooltip-override" title="Accepts local format (eg. 04 1234567, 050 1234567 or 04-1234567, 050-1234657)<br />and international format (eg. +971 41234567, +971-41234567 ).<br />Also accepts an optional extention of up to four digits (eg. 04 1234567 289 or +974 41234567 289)">
<asp:Image ID="imgtooltip" CssClass="tooltip-img" runat="server" ImageUrl="~/images/tooltipgreen.png" />
</div>
</div>
<div class="row-form">
<div class="row-lbl-wrapper">
<asp:Label ID="lblFax" runat="server" CssClass="row-label" Text="Fax Number:"></asp:Label>
</div>
<asp:TextBox ID="txtFax" runat="server" CssClass="row-input"></asp:TextBox>
<asp:RegularExpressionValidator ID="revFax" runat="server" ErrorMessage="*" ValidationGroup="Careers" ControlToValidate="txtFax" ValidationExpression="^([\+]?[0-9]{1,3}[\s.-][0-9]{1,12})$"></asp:RegularExpressionValidator>
<div class="tooltip tooltip-override" title="Accepts local format (eg. 04 1234567 or 040-1234567)<br />and international format (eg. +974 41234567 or +974-41234567)">
<asp:Image ID="Image1" CssClass="tooltip-img" runat="server" ImageUrl="~/images/tooltipgreen.png" />
</div>
</div>
<div class="row-form">
<div class="row-lbl-wrapper">
<asp:Label ID="lblAddress" runat="server" CssClass="row-label" Text="Address:"></asp:Label>
</div>
<asp:TextBox ID="txtAddress" runat="server" CssClass="row-input-multiline" TextMode="MultiLine"></asp:TextBox>
</div>
<div class="row-form">
<div class="row-lbl-wrapper"> <span class="row-req">*</span>
<asp:Label ID="lblCountry" runat="server" CssClass="row-label" Text="Country:"></asp:Label>
</div>
<asp:DropDownList ID="ddCountry" runat="server" CssClass="row-dd"></asp:DropDownList>
<asp:CascadingDropDown ID="csdCountry" runat="server" Category="Country" TargetControlID="ddCountry" PromptText="-- Select --" LoadingText="[Loading Countries...]" ServiceMethod="FetchCountries" ServicePath="~/wsCountryCity.asmx" PromptValue="0"></asp:CascadingDropDown>
<asp:RequiredFieldValidator ID="rfCountry" ValidationGroup="Careers" ControlToValidate="ddCountry" CssClass="row-validate" InitialValue="0" runat="server" ErrorMessage="*"></asp:RequiredFieldValidator>
</div>
<div class="row-form">
<div class="row-lbl-wrapper">
<asp:Label ID="lblCity" runat="server" CssClass="row-label" Text="City:"></asp:Label>
</div>
<asp:DropDownList ID="ddCity" runat="server" CssClass="row-dd"></asp:DropDownList>
<asp:CascadingDropDown ID="csdCity" runat="server" Category="City" TargetControlID="ddCity" ParentControlID="ddCountry" PromptText="-- Select --" LoadingText="[Loading Cities...]" ServiceMethod="FetchCities" ServicePath="~/wsCountryCity.asmx" PromptValue="0"></asp:CascadingDropDown>
</div>
<div class="row-form">
<div class="row-lbl-wrapper"> <span class="row-req">*</span>
<asp:Label ID="Label1" runat="server" CssClass="row-label" Text="CV:"></asp:Label>
</div>
<asp:FileUpload ID="FileUpload1" runat="server" CssClass="fileUpload" />
<div id="dFileUpload1" class="btnUploadHack">Browse</div>
<asp:Button ID="btnUploadCV" runat="server" Text="Upload" CssClass="btnUpload" onclick="btnUploadCV_Click" />
<asp:RequiredFieldValidator ID="rfvF1" runat="server" ValidationGroup="Careers" ErrorMessage="*" CssClass="row-validate" ControlToValidate="FileUpload1"></asp:RequiredFieldValidator>
<asp:Label ID="lblImageMSG" runat="server" Text=""></asp:Label>
</div>
<div class="contactus-row">
<asp:Button ID="btnSave" runat="server" CssClass="btnContactUsSave" Text="Send Message" onclick="btnSave_Click" ValidationGroup="Careers" />
</div>
</asp:Panel>
<asp:Panel ID="pnlCareerMSG" runat="server"></asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
<!-- UpdatePanel -->
</div>
</div>
<div class="pg-right-bar">
<asp:Image ID="imgSideBanner" runat="server" />
</div>
</div>
<!-- page content wrapper -->
<!-- Content Page-->
</asp:Content>
Code Behind
protected void btnUploadCV_Click(object sender, EventArgs e)
{
// code is here
}
So far i am not able to figure out what i s blocking the any button inside from firing. Yes i did even put a simple button to test even that didn't fire.
I am not sure if it is Validation or Update Panel which is creating problem.
I tried using Trigger that didnt work
I tried setting
<asp:Button ID="btnUploadCV" runat="server" Text="Upload" CssClass="btnUpload" onclick="btnUploadCV_Click" CausesValidation="false" />
protected void btnUploadCV_Click(object sender, EventArgs e)
{
Page.Validate();
if (Page.IsValid == true)
{
// your code here
}
}
My problem is it deosn't even enter code block of button for some reason.
Just to add further i am using cascading dropdown for country and cities i am not sure if that is causing any problem I am also using two panels one has the form control and after successful submission i hide this panel & show the other panel with success message all this code with UpdatePanel.
Only way out of this i see is to upload all files main form button Send Message rather than having individual button for all file upload control
UPDATE: I also tried this approach even this doesn't work
Please understand the concept
Update Panel is used for partial post back which is today we call AJAX
However AJAX cannot be used to upload file to the server
AJAX uses xmlHttpRequest which do not support file upload.
So, don't think that its a bug from Microsoft. Even today also, we don't have any javascript library which will support FileUpload using AJAX. All AJAX fileuploaders that you find on internet are using Flash :)
This is the limitation of protocol. Use any other jquery plugin to upload file. Update panel will not work for this.
FileUpload control doesn't work with asynchronous postbacks.To make this work in your application, follow below steps
1.) Place a <asp:ScriptManager /> on the page.
if you are using master page in your application and your web page uses the master page, place script manager in master page. If you don't want master page to have script manager,you can also place script manager on specific web pages anyways.
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
2.) After this, Add <Triggers> for the button btnUploadCV in your Update panel.
<Triggers>
<asp:PostBackTrigger ControlID="btnUploadCV" />
</Triggers>
And rest of your upload button OnClick handler looks like:
protected void btnUploadCV_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
fileName = FileUpload1.FileName;
FileUpload1.SaveAs("~/UploadedData/" + fileName);
...
}
}

Show a Loading Message using master pages while page loads data asp.net

I have spent hours Googling and searching past questions but have struggled to get anywhere with those answers (be it I can't get it into my solution correctly or it isn't suitable for me as they don't have master pages).
My question is, I have a couple of asp.net pages which can take a while to load (sometimes 5 seconds+) as there is a lot of data being requested from a database on the Page_Load method. To stop users from thinking that the page has crashed and either refreshing the page or doing something else, I want to put up a Loading message hiding everything else on the page (apart from the menu) while it loads.
I am using ASP.Net 4.0 with master pages and coding in C#.
The one where I get the most success is using the UpdatePanel on my master page where the content template covers the contentplaceholder, however I know this is not the best way to go about it and anyway it only shows up once, i.e. The user logs in, the loading message appears and once all the data has loaded on the home page (dashboard.aspx) the loading message disappears, which is kind of what I want. However if the user goes away from that page and then clicks home the loading message never appears again, just takes a while to load. It also never appears for any other page that takes a noticeable time to load.
Below is the body of the master.aspx
<body>
<form runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div class="page">
<div class="header">
<div class="title">
<h1>
Header
</h1>
</div>
<div class="loginDisplay">
<asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
<AnonymousTemplate>
[ Log In
]
</AnonymousTemplate>
<LoggedInTemplate>
Welcome <span class="bold">
<asp:LoginName ID="HeadLoginName" runat="server" />
</span>! [
<asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out"
LogoutPageUrl="~/Default.aspx" />
]
</LoggedInTemplate>
</asp:LoginView>
</div>
<div class="clear hideSkiplink">
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false"
IncludeStyleBlock="false" Orientation="Horizontal" OnMenuItemClick="NavigationMenu_MenuItemClick">
<Items>
<asp:MenuItem Text="Home" />
<asp:MenuItem Text="About" />
</Items>
</asp:Menu>
</div>
</div>
<div class="main">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<asp:Panel ID="Panel1" runat="server" HorizontalAlign="Center">
<asp:Image ID="Image1" runat="server" ImageUrl="~/Images/loader.gif" />
</asp:Panel>
</ProgressTemplate>
</asp:UpdateProgress>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanelAnimationExtender ID="UpdatePanel1_UpdatePanelAnimationExtender"
runat="server" Enabled="True" TargetControlID="UpdatePanel1">
</asp:UpdatePanelAnimationExtender>
</div>
<div class="clear">
</div>
</div>
<div class="footer">
</div>
</form>
And below is the page for the dashboard.aspx (a page which has a long loading time)
<asp:Panel ID="PanelWelcome" runat="server">
<h1>
Welcome
<asp:Label ID="LabelUserName" runat="server" Text="[User Name]" /> to your
personal Dashboard.</h1>
<table width="100%" cellpadding="5px">
<tr>
<td style="width: 70%" valign="top">
<asp:Panel ID="Panel2" runat="server">
<p>
</p>
<h4>
Up and Coming </h4>
<br />
<asp:GridView ID="GridViewItin" runat="server" Width="100%" HorizontalAlign="Left"
OnRowDataBound="GridViewItin_RowDataBound">
</asp:GridView>
</asp:Panel>
</td>
<td style="width: 30%">
<asp:Panel ID="PanelProfile" runat="server">
<asp:ImageButton ID="ImageButtonProfile" runat="server" ImageUrl="~/Images/BlankProfile.jpg"
Width="150px" /><br />
<h4>
Name:</h4>
<asp:Label ID="LabelPARname" runat="server" Text="[Person Name]"></asp:Label>
<h4>
Company:</h4>
<asp:Label ID="LabelBARname" runat="server" Text="[Company Name]"></asp:Label>
<h4>
Date of Birth:</h4>
<asp:Label ID="LabelPARdob" runat="server" Text="[DOB]"></asp:Label><br />
<asp:LinkButton ID="LinkButtonProfilePage" runat="server" OnClick="LinkButtonProfilePage_Click">More details...</asp:LinkButton>
</asp:Panel>
</td>
</tr>
</table>
</asp:Panel>
Could you please show me the best way to go about it and where I am going wrong? Also how I can hide the ContentTemplate when the UpdateProgress template is showing that would be great?
Thanks.
Okay so I figured it out what I was doing wrong, I thought I would post what I did to hopefully help someone else who might end up with the same issues...
Basically I hadn't thought about it logically. There are controls outside the update panel such as a NavigationMenu which would never fire the update progress because they had nothing to do with the Panel! I had to add triggers to the update panel to deal with all the things that happen outside the panel.
So, in my master page I had the following code
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="NavigationMenu" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdateProgress ID="progress" runat="server" DynamicLayout="true" DisplayAfter="0">
<ProgressTemplate>
<div id="overlay">
<div id="modalprogress">
<div id="theprogress">
<asp:Image ID="loader" runat="server" ImageAlign="AbsMiddle" ImageUrl="~/images/loader.gif" />
Please wait...
</div>
</div>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanelAnimationExtender ID="UpdatePanel1_UpdatePanelAnimationExtender"
runat="server" Enabled="True" TargetControlID="UpdatePanel1">
</asp:UpdatePanelAnimationExtender>
Hopefully that will help someone else!
You can use UpdateProgress control. You can get it From Toll box under Ajax Extensions Tab.
I am describing you a scenario:
Suppose I have One Upadate Panel name UpdatePnl1 , In that I have a Button Say GO.when we hit on go it should redirect to another page. before that it will promt you please wait.
Now my Code will be like that
<asp:UpdatePanel ID="UpdatePnl1" runat="server">
<ContentTemplate>
<asp:Button ID="BtnGO" runat="server" Text="GO" onclick="BtnGO_Click"/>
</ContentTemplate>
</asp:Updatepanel>
Button click code:
protected void BtnGO_Click(object sender, EventArgs e)
{
Response.Redirect("Example.aspx");
}
Now here is the code for UpdateProgress what you need to add
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePnl1" >
<ProgressTemplate>
<asp:Label ID="LblWaitMsg" runat="server" Text="Processing Request, Please Wait..."></asp:Label>
</ProgressTemplate>
</asp:UpdateProgress>
Note: Your page Should contain ScriptManager.

Categories