How to hide the page on load indicating in asp.net - asp.net

I am using ASP.NET 2.0 and AJAX extension tool.
I already created loading indicator on button submit. When I will click the button, the loading indicator will show after redirecting to the next page. But, I want to hide the page until processing has completed (after that redirect to next page).
I am using the following code:
<td style="width: 100px; height: 26px;">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdateProgress ID="UpdateProgress1" DynamicLayout="false" runat="server">
<ProgressTemplate>
<img src="Images/loading.gif" alt="Images/loading.gif" style="z-index: 100; left: 21px; position: absolute; top: 64px" />
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<dx:ASPxButton ID="btnOk" ClientInstanceName="btnok" runat="server" Style="z-index: 100; left: 90px; position: absolute;
top: 108px" Text="OK" Width="61px" BackColor="Gainsboro" OnClick="btnOk_Click" AutoPostBack="False" >
<DisabledStyle>
<Border BorderColor="Teal" />
</DisabledStyle>
<ClientSideEvents Click="function(s, e) {
ShowloadingImage();
}" />
</dx:ASPxButton>
</ContentTemplate>
</asp:UpdatePanel>

To "hide" your page you can make an overlay div over all, using this css
.OverAll
{
height:100%;
width:100%;
position:fixed;
left:0;
top:0;
z-index:2 !important;
background-color:black;
}

using jquery we can hide the page on page loading...I am using following code
$(function() {
($.unblockUI);
$('#pnlLogin_btnOk').click(function() {
$.blockUI({ message: '<img src="Images/loading.gif" />' });
});
});

Related

Ajax modalpopupextender not popping up

.modalBackground
{
background-color: Gray;
filter: alpha(opacity=70);
opacity: 0.7;
}
.modalPopup
{
background-color: #ddffdd;
border-width: 3px;
border-style: solid;
border-color: Gray;
margin-top: 60px;
padding: 2px;
width: 400px;
font-size: 10pt;
}
<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" CancelControlID="Button3"
OkControlID="btnOk" TargetControlID="LinkButtonDummy" PopupControlID="PanelPopUp"
BackgroundCssClass="modalBackground" />
<asp:Panel ID="PanelPopUp" runat="server" CssClass="modalPopup" Style="display: none">
<div>
<asp:Label ID="lblMsg" runat="server" />
<asp:Button ID="Button2" runat="server" Text="Add New Organisation" OnClick="Button2_Click" />
<asp:Button ID="Button3" runat="server" Text="Cancel" />
</div>
</asp:Panel>
I have also included the AJAX reference and a ScriptManager on the master page.
I have to add an enhancement to an existing page and I'm quite new with ASP.NET, the page in question is a 'content page' and is linked to a master page (containing the scriptmanager).
This code all looks completely fine and I have been reading on this for over three hours now but to no avail - my modal doesn't 'pop-up' and grey the background out, it simply appears where I have placed it on the page (right at the top, or right at the bottom e.t.c.) as if I was just showing/hiding a div.
Can anyone help, I'm going crazy?
What other routes can I go down for adding a confirmation box on a page that takes a string built in the code-behind and also runs code-behind functions on OK/Cancel?
Keep your css as it it and try this code :
<asp:HiddenField ID="HiddenField1" runat="server" />
<asp:ModalPopupExtender ID="MyPopup" runat="server" CancelControlID="Button3" OkControlID="btnOk" PopupControlID="PanelPopUp" BackgroundCssClass="modalBackground" DynamicServicePath="" Enabled="True"
TargetControlID="HiddenField1"></asp:ModalPopupExtender>
and on Button2_Click event add
MyPopup.Show();

Ajax modal popup position on small screens

I have the following modal popup on a Asp.net/C# web application. The modal popup holds multiple placeholders. My problem occurs when I am trying to access the modal popup on small screens or on ipad/iphone/ipod screens. The page display the half of the modal popup so the information in the top are inaccessible. I have used overflow:auto;/ the following solution: Mobile ModalPopupExtender? and many others but doesn’t solved my problem.
.modalBackground {
background-color:Gray;
filter:alpha(opacity=70);
opacity:0.7; } .modalPopup {
background-color:#ffffdd;
border-width:3px;
border-style:solid;
border-color:Gray;
padding:3px;
width:250px; }
<asp:Panel ID="Panel1" runat="server"></asp:Panel>
<asp:Button ID="btnShowPopup" runat="server" style="display:none" />
<asp:ModalPopupExtender ID="ModalPopupExtender1" PopupDragHandleControlID="Panel1" RepositionMode="None" runat="server" PopupControlID="pnlpopup"
TargetControlID="btnShowPopup" CancelControlID="btnCancel"
DropShadow="true"
BackgroundCssClass="modalBackground">
</asp:ModalPopupExtender>
<asp:Panel ID="pnlpopup" runat="server" BackColor="LightGray" style="display:none;"
CssClass="modalPopup" Width="650px" >
<asp:UpdatePanel ID="UpdatePanel3" UpdateMode="Conditional" runat="server">
<ContentTemplate>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Button ID="btnCancel" Height="30px" Width="160px" runat="server" Text="Cancel" />
</asp:Panel>
#focus: As I am using Jquery to attach ModalPopup to a button but code I used to check innerheight and then add class to my panel is:
var height = window.innerHeight;
if (height < 1000) {
$("#pnlpopup").addClass("PanelWithScroll");
}
You need to add above code in javascript and this need to be called on ModalPopupExtender click.
PanelWithScroll is a css class:
.PanelWithScroll{
height:250px;
overflow:scroll;
overflow-x:hidden;
}
Similarly, if you have problem with width too, you can check width too (http://responsejs.com/labs/dimensions/) and change class PanelWithScroll
Other thing you can do is check page height on page_load and if its less than what you want, add this class to pnlpopup Div. (This is easy solution IMO)
Update:
Add given javascript in your HTML Code in head section
$(document).ready(function () {
var height = window.innerHeight;
if (height < 1000) {
$("#pnlpopup").addClass("PanelWithScroll");
}
}
$(document).ready will only run after your page has wholly rendered. This may also help if you need help on how to put script in html (http://javascript.info/tutorial/adding-script-html)

asp.net on button click UpdateProgress shows progress bar and then ModalPopextender for errors combintaion

So I'm trying to understand how this should be properly setup. I have a Updateprogress that shows a progress bar when a button is clicked. The button is wrapped in an UpdatePanel. But if there're any error, I want to stop the processing and then pop up a modal window (I used Modalpopupextender) to show the errors. My issue is, it just shows the box (or object) but without the texts that came from the Exception. Here's my code:
<asp:UpdatePanel ID="UpdatePanel_ActionButtons" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Approve" OnClick="Proccess_Click1" OnClientClick="this.disabled = true; this.value = 'Processing';" UseSubmitBehavior="false" />
</ContentTemplate>
</asp:UpdatePanel>
The Progress Bar:
<asp:UpdateProgress ID="UpdateProgress" runat="server" AssociatedUpdatePanelID="UpdatePanel_ActionButtons">
<ProgressTemplate>
<div style="background-color:Gray; filter:alpha(opacity=80); opacity:0.80; width: 100%; top: 0px; left: 0px; position: fixed; height: 800px;"></div>
<div style=" filter:alpha(opacity=100); position: fixed;
z-index: 100001;
left: 720px;
top: 105px;">
<div style="width:50px; height:50px; padding:50px; background-color:white; border:solid 1px black;">
<img alt="progress" src="../images/ajax-waiting.gif"/>
Processing...
</div>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
The error box:
<asp:LinkButton ID="btnNotInUse" runat="server" />
<ajaxtoolkit:ModalPopupExtender ID="qaError" runat="server"
TargetControlID="btnNotInUse"
PopupControlID="pnlQAError"
BackgroundCssClass="modalPopupExtender" />
<asp:Panel ID="pnlQAError" runat="server" Style="display: none" CssClass="modalPopup">
<br />
<asp:Button ID="OkBtn" runat="server" Text="Ok" OnClick="OkBtn_Click" />
</asp:Panel>
Button Click Method:
protected void Proccess_Click1(object sender, EventArgs e)
{
List<string> validationErrors;
string returnurl;
Processrecord(out validationErrors);
if (validationErrors.Count() > 0)
{
foreach (var error in validationErrors)
{
qaFeedback.InnerHtml += error;
}
qaError.Show();
return;
}
else
{
returnurl = "toanotherpage.aspx";
}
}
So if you look as to how I add the errors, it's adding it to the "qafeedback" div. And then I would force it to show up and then return. What's happening is it would pop out the button box, with the button, but it doesn't show the texts I added. It would be helpful to know as well that when I remove the progress bar or animation, the whole thing works or shows the error messages.
Thoughts?

ModalPopupExtender Button Problem

I am trying to figure out why my ModalPopupExtender keeps closing, everytime a user clicks either button its running the code behind because I put a break point in and it is breaking there, but the modalPopup immediately closes, which isnt good because if it has any errors in the process they cant be displayed. So how do I stop the modalpopup from closing itself? I didnt specify a OKControlID or a CancelControlID.
Panel Code:
<asp:Panel ID="Panele" runat="server" style="display: none; position:absolute; top: 50%; left: 35%; width: 500px; height: 350px; background-color: White; border: solid 1px black; padding-left: 15px; text-align: left;">
<asp:ImageButton ID="CloseEBtn" runat="server"
ImageUrl="images/CloseButton.png" style="float: right; margin-right: 3px; margin-top: 3px;"
onclick="CloseEBtn_Click" />
<strong>Name:<asp:TextBox ID="fromTextBox" runat="server"></asp:TextBox></strong>
<asp:Button ID="SndBtn" runat="server" Text="Send" onclick="SndBtn_Click" />
<asp:Button ID="ClrBtn" runat="server" Text="Clear" />
<br />
<br />
<asp:Label ID="msglabel" runat="server"></asp:Label>
</asp:Panel>
My ModalPopupExtender Code:
<asp:ModalPopupExtender ID="popup" runat="server"
TargetControlID="SIBtn" PopupControlID="Panele" BackgroundCssClass="modalBackground">
</asp:ModalPopupExtender>
CodeBehind:
protected void SndBtn_Click(object sender, EventArgs e)
{
msglabel.Text = "The Window Didnt Close";
}
protected void ClrBtn_Click(object sender, EventArgs e)
{
fromTextBox.Text = "";
toTextBox.Text = "";
subjectTextBox.Text = "";
MessageTextBox.Text = "";
msglabel.Text = "";
}
By code-behind running if you mean the page posts back, modal popups do not explicitly reload themselves. You have to write some code from the server to show the Modal Popup; there is a Server-side Show() method on the extender and a client-side show() method like:
$find("<%= mpe.ClientID %>").show();
HTH.
For me, UseSubmitBehavior="false" on the asp:Button did the trick.

Best "Loading" feedback for ASP.Net?

So, we have an ASP.Net application - fairly standard - and in there are lots of updatepanels, and postbacks.
On some pages we have
<ajax:UpdatePanelAnimationExtender ID="ae" runat="server" TargetControlID="updatePanel" BehaviorID="UpdateAnimation">
<Animations>
<OnUpdating>
<FadeOut Duration="0.1" minimumOpacity=".3" />
</OnUpdating>
<OnUpdated>
<FadeIn minimumOpacity=".5" Duration="0" />
</OnUpdated>
</Animations>
</ajax:UpdatePanelAnimationExtender>
Which basically whites out the page when a postback is going on (but this clashes with modal dialog grey backgrounds). In some cases we have a progressupdate control which just has a spinny icon in the middle of the page.
But none of them seem particularly nice and all a bit clunky. They also require a lot of code in various places around the app.
What methods do other people use and find effective?
i havent used the UpdatePanelAnimationExtender but an UpdateProgress-Control in combination with an animated gif(Bermos Link):
<asp:UpdateProgress ID="UpdateProgress1" DynamicLayout="true" runat="server" AssociatedUpdatePanelID="UdpImeiLookup" DisplayAfter="500" >
<ProgressTemplate>
<div class="progress">
<img src="images/ajax-loader-arrows.gif" /> please wait...
</div>
</ProgressTemplate>
</asp:UpdateProgress>
The ProgressTemplate will be visible on every Postback of the associated Update Panel(after 500ms in this example).
EDIT: where class "progress" can be f.e. this:
.progress
{
text-align:center;
vertical-align:middle;
position: absolute;
left: 44%;
top: 35%;
border-style:outset;
border-color:silver;
background-color:Silver;
white-space:nowrap;
padding:5px;
}
Regards,
Tim
Like the others, I suggest to use the UpdateProgress in a modal popup.
I will add this twist, put the popup, UpdateProgress and this code in a masterpage, so whenever you need it, just plug the masterpage to the content page.
<script type="text/javascript">
var ModalProgress ='<%= ModalProgress.ClientID %>';
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginReq);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endReq);
function beginReq(sender, args){
// shows the Popup
$find(ModalProgress).show();
}
function endReq(sender, args)
{
// hide the Popup
$find(ModalProgress).hide();
}
</script>
here some ref:
http://mattberseth.com/blog/2007/07/modalpopup_as_an_ajax_progress.html
http://vincexu.blogspot.com/2008/10/how-to-make-modalupdate-progress-bar-on.html
Animated gifs require the least amount of code and you can select your favourite one with whatever colours you please from the following site - Ajaxload - Ajax loading gif generator.
This is what I use, it has a modal popup type background and a gif
<asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="0">
<ProgressTemplate>
<div style="position: absolute; width: 100%; height: 100%; z-index: 100; background-color: Gray;
filter: alpha(opacity=70); opacity: 0.7;">
</div>
<table style="position: absolute; width: 100%; height: 100%; z-index: 101;">
<tr>
<td align="center" valign="middle">
<div style="color: Black; font-weight: bolder; background-color: White; padding: 15px;
width: 200px;">
<asp:Image ID="Image3" runat="server" ImageUrl="~/Images/progress.gif" />
Please wait....
</div>
</td>
</tr>
</table>
</ProgressTemplate>

Resources