Showing posts with label position. Show all posts
Showing posts with label position. Show all posts

Wednesday, March 28, 2012

UpdateProgress Position in middle of screen

Hi,

I have various updatepanels on the same page. I want to have 1 updateprogress on the same page and depending on which updateprogress is updating that the updateprogress move to the middle of the updateprogress that is updating. The following code below allows me to position the updateprogress in the centre of the page but when the the page is scrolled down the updateprogress doesn't move its position appropriately.

Can anyone help?

I have inspected the values of the document.body.scrolltop and it is always at 0. How can change the position of the updateprogress when the user scrolls the page?

<

scriptlanguage="javascript"type="text/javascript">

function

adjustDivs(){var df=document.getElementById("updateprogressdiv");

df.style.position=

'absolute' ;

df.style.left =document.body.offsetWidth/2 + document.body.scrollLeft -150;

df.style.top = document.body.offsetHeight/2 + document.body.scrollTop -50;

}

window.onload=adjustDivs;

window.onresize=adjustDivs;

window.onscroll=adjustDivs;

</

script>

did you ever figure how to make the updateprogress display in the center of the page even when you scroll the page down

or does anybody have any other ides on how to make this happen


hello.

you can easilly do that with the AllwaysVisibleControlExtender available on the atlas toolkit.


Hi,

I've come up with some DHTML to always center the animated gif on your screen, AS WELL AS disable all elements by throwing a transparent IFRAME z-indexed to the top. Keep in mind that I have NOT tested this with other browsers, only in IE6. If anyone wants to cross-browser/cross-platform modify it, be my guest.

<atlas:UpdateProgressID="uppMain"runat="server">

<ProgressTemplate>

<iframeframeborder="0"src="about:blank"

style="border:0px;position:absolute;z-index:9;left:0px;top:0px;width:expression(this.offsetParent.scrollWidth);height:expression(this.offsetParent.scrollHeight);filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=75, FinishOpacity=0, Style=0, StartX=0, FinishX=100, StartY=0, FinishY=100);"></iframe>

<divstyle="position:absolute;z-index:10;left:expression((this.offsetParent.clientWidth/2)-(this.clientWidth/2)+this.offsetParent.scrollLeft);top:expression((this.offsetParent.clientHeight/2)-(this.clientHeight/2)+this.offsetParent.scrollTop);">Please Wait...<br/><imgsrc="/_images/statusbar.gif"/></div>

</ProgressTemplate>

</atlas:UpdateProgress>


Works Perfect..Big Smile..Thanks for the code...

Okay... dude... that "left: expression((t..." line is absolute GENIUS!!! I had NO idea that you could do that! It even works in a stylesheet!

You are the MAN! Unless you're a girl, in which case you're... well, still the man! :D


Seriously, you guys couldn't have bumped this thread a couple hours ago? I just finished my own attempt at using UpdateProgress to disable page controls... and yours is better. :(

Umm,

I was under the impression that CSS "expression" is not standard. I know it works in IE, but does it work in Firefox. I know we've had problems before, because I don't think Firefox recognizes it. I could be wrong, though. You might want to cross-browser test it.


Hi guys/gals,

Tadmeister's introduction of Javascript within CSS was absolutely brilliant i thought also. So along with some help from another article on some Javascript i decided to do some customisation of my own. But instead of using an iframe (if anyone has a problem with it), I used a Panel for the overlay and another Panel within it for the "loading..." text. Here is a snippet in case anyone wants to try it out. I've tested it and it works nicely in Firefox2 & IE7, but IE6 gave me some problems with the vertical positioning. I used a hack for IE6, and anyone is welcome to improve on it!

<ajax:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<asp:Panel ID="Panel1" CssClass="overlay" runat="server">
<asp:Panel ID="Panel2" CssClass="loader" runat="server">
Loading...
</asp:Panel>
</asp:Panel>
</ProgressTemplate>
</ajax:UpdateProgress>

and the CSS for it:

.overlay {
position: fixed;
z-index: 99;
top: 0px;
left: 0px;
background-color: #FFFFFF;
width: 100%;
height: 100%;
filter: Alpha(Opacity=70);
opacity: 0.70;
-moz-opacity: 0.70;
}
* html .overlay {
position: absolute;
height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px');
width: expression(document.body.scrollWidth > document.body.offsetWidth ? document.body.scrollWidth : document.body.offsetWidth + 'px');
}
.loader {
z-index: 100;
position: fixed;
width: 120px;
margin-left: -60px;
top: 50%;
left: 50%;
}
* html .loader {
position: absolute;
margin-top: expression((document.body.scrollHeight / 4) + (0 - parseInt(this.offsetParent.clientHeight / 2) + (document.documentElement && document.documentElement.scrollTop || document.body.scrollTop)) + 'px');
}

Yea, I know...the margin-top expression for IE6 is not the best, but if someone can make it work properly, be my guest. Alternatively check out: www.codeproject.com/ajax/modalupdateprogress.asp for Ting Huang's custom ajax extender.

Cheers!
Shalan99


Is there a way to get this to cover only a div or something? I have some web parts that do updates, and would like it to be centered within those, but I can't get that to work.

Hi Sarvis,

There are ways to achieve this. Raj Kaimal has a great bunch of control/extenders...one of which does what u want it to do, minus centering it in the associated control itself. Check it out @.: http://weblogs.asp.net/rajbk/archive/2007/01/08/using-the-updateprogress-control-as-a-modal-overlay.aspx

Another way to do this jus came to mind, but let me test it out first before i post any code.


Cheers!


Thank you very much. Great post. Tadmeister


Hi Tadmeister,

I implemented above code it worked, but receiving CSS validation is not valid for property left/top. How do I avoid receiving these error in .aspx page.

Please help...


Thanks for that, works fine

updateprogress position in Firefox (urghh!)

Hi,

I have an updateprogress control that displays nicely in the middle of the screen, but only in IE.

The code is...

<

atlas:UpdateProgressid="loadingProgress"runat="server"><ProgressTemplate>

<divstyle="height:40px;width:250px;position:absolute;z-index:10000;left:expression((this.offsetParent.clientWidth/2)-(this.clientWidth/2)+this.offsetParent.scrollLeft);top:expression((this.offsetParent.clientHeight/2)-(this.clientHeight/2)+this.offsetParent.scrollTop+58); background-repeat: repeat-x; text-align: center; vertical-align: middle; border-right: black 1px solid; border-top: black 1px solid; border-left: black 1px solid; border-bottom: black 1px solid; background-image: url(Images/updateProgressBk.png);">

<

imgstyle="z-index: 109; left: 80px; position: absolute;top:22px"src="images/progressbar_microsoft.gif"/></div></ProgressTemplate></atlas:UpdateProgress> But in Firefox (dont like it myself but some users here use it), it positions on the top left of the screen.

Anyone know a fix, or does Firefox not know about "this.offsetParent.clientHeight" etc?

Thanks

Anyone know how to position the update progress control in the center of the page when viewing from Firefox?

Wednesday, March 21, 2012

Use Atlas profile service to persist layout between sessions

This sample use Atlas profile service to persist the position of a drag and drop panel between browse sessions.

Send me a private message if you like to have a zip file includes everything for this sample.


<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<atlas:ScriptManager runat="server" ID="ScriptManager1">
<Scripts>
<atlas:ScriptReference ScriptName="AtlasUIDragDrop" />
</Scripts>
</atlas:ScriptManager>
</head>
<body>
<form id="form1" runat="server">
<span id="msg"></span>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="200px" height="400px"> </td>
<td>
<div id="imagePanel" style="background-color:Navy;padding:1px">
<div id="dragHandler" style="background-color:Navy;width:100%;"></div>
<img src="http://pics.10026.com/?src=http://www.google.com/intl/en/images/logo.gif" />
</div>
</td>
</tr>
</table>
</form>

<script type="text/xml-script">
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components>
<control id="imagePanel">
<behaviors>
<floatingBehavior handle="dragHandler" move="OnMove" />
</behaviors>
</control>
</components>
</page>
</script>

<script type="text/javascript">
function pageLoad()
{
Sys.Profile.set_autoSave(false);
Sys.Profile.loaded.add(onProfileLoadComplete);
Sys.Profile.saved.add(onProfileSaveComplete);
Sys.Profile.load();
}

function onProfileLoadComplete()
{
var objStyle = $object('imagePanel').element.style
objStyle.posTop = Sys.Profile.properties.poxTop;
objStyle.posLeft = Sys.Profile.properties.poxLeft;
}

function onProfileSaveComplete()
{
//alert('profile saved.');
}

function OnMove(sender, cancelArgs)
{
var ele = sender.control.element
Sys.Profile.properties.poxTop = ele.offsetTop;
Sys.Profile.properties.poxLeft = ele.offsetLeft;
Sys.Profile.save();
}
</script>
</body>
</html>

Your web.config must include something similar to the following. also you need a database to host the asp.net AppService.

<configSections>
<sectionGroup name="microsoft.web" type="Microsoft.Web.Configuration.MicrosoftWebSectionGroup">
<section name="profileService" type="Microsoft.Web.Configuration.ProfileServiceSection" requirePermission="false"/>
</sectionGroup>
</configSections>

<microsoft.web>
<profileService enabled="true"
setProperties="poxTop;poxLeft"
getProperties="poxTop;poxLeft">
</profileService>
</microsoft.web>

<connectionStrings>
<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf" />
</connectionStrings>

<system.web>
<anonymousIdentification enabled="true" />
<profile>
<properties>
<add name="poxTop" type="integer"/>
<add name="poxLeft" type="integer"/>
</properties>
</profile>
</system.web>

I'm getting javascript errors trying to use this.

Sys.Profile.loaded.add(onProfileLoadComplete);
Sys.Profile.saved.add(onProfileSaveComplete);

should be

Sys.Profile.loaded.add(onProfileLoadComplete());
Sys.Profile.saved.add(onProfileSaveComplete());

then

Sys.Profile.properties.poxTop is null or not an object.


oh...

Sys.Profile.loaded.add(onProfileLoadComplete);
Sys.Profile.saved.add(onProfileSaveComplete);

is correct. this is demo, ignore the javascript error and the second try will let you go i think.


Great Example, thanks!

2 things:

1. I changed the example slighlty to display the Profile-Save-Event Time to the StatusBar with this
Script:

window.status = Date();

Does work well, but the Date is formatted this strange way:

Fri, May 19 09:26:32 2006

So the time is in the middle of the date-part !?

2. Does anybody have the same example but working more with the Server-Side Atlas-Framework?

Thanks


please send me zip file includes everything for this sample

Hi Xiyuan Shen

Can you send me the zip file so that I can implement this...I have been partially sucessfull. It seems as though I am missing a step though.

Justin


Did you actually get this working?

I have the example loaded and it seem to initially work, however, the drag N drop page moves once the page is completely loaded, to the top left of the screen. Any ideas why?


Hi there

Here is my code. He will do the job.

You get the error "Sys.Profile... length is null" if your database, which is responsible to save and where you get the position-values, is not running or not accessible.

Good luck.

Patrick

Web.Config

<?xmlversion="1.0"?>

<configuration>

<configSections>

<sectionGroupname="microsoft.web"type="Microsoft.Web.Configuration.MicrosoftWebSectionGroup">

<sectionname="webServices"type="Microsoft.Web.Configuration.WebServicesSection"requirePermission="false"/>

<sectionname="profileService"type="Microsoft.Web.Configuration.ProfileServiceSection"requirePermission="false"/>

</sectionGroup>

</configSections>

<microsoft.web>

<!-- Enable WebServices because Profile-Service ASP.NET is accessible thru WS-->

<webServicesenableBrowserAccess="true"/>

<profileService

enabled="true"

setProperties="poxTop;poxLeft;FloatingLabelLocation"

getProperties="poxTop;poxLeft;FloatingLabelLocation">

</profileService>

</microsoft.web>

<system.web>

<authenticationmode="Windows"/>

<anonymousIdentificationenabled="true"/>

<profileenabled="true">

<properties>

<addallowAnonymous="true"name="FloatingLabelLocation"/>

<addname="poxTop"type="integer"/>

<addname="poxLeft"type="integer"/>

</properties>

</profile>

<pages>

<controls>

<addnamespace="Microsoft.Web.UI"assembly="Microsoft.Web.Atlas"tagPrefix="atlas"/>

<addnamespace="Microsoft.Web.UI.Controls"assembly="Microsoft.Web.Atlas"tagPrefix="atlas"/>

</controls>

</pages>

<compilationdebug="true" />

<httpHandlers>

<removeverb="*"path="*.asmx"/>

<!-- ASMX is mapped to a new handler so that proxy javascripts can also be served.-->

<!-- Otherwise, you get the following error-->

<!-- The HTTP verb POST used to access path '/ProfileWithAtlas/ScriptServices/Microsoft/Web/Services/Standard/ProfileWebService.asmx' is not allowed.-->

<addverb="*"path="*.asmx"type="Microsoft.Web.Services.ScriptHandlerFactory"validate="false"/>

</httpHandlers>

</system.web>

</configuration>

------------

<%@.PageLanguage="C#"AutoEventWireup="true" %>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headrunat="server">

<title>Atlas Profiling</title>

</head>

<body>

<formid="form1"runat="server">

<atlas:ScriptManagerrunat="server"ID="ScriptManager1">

<Scripts>

<atlas:ScriptReferenceScriptName="AtlasUIDragDrop"/>

</Scripts>

</atlas:ScriptManager>

<spanid="msg"></span>

<tablecellpadding="0"cellspacing="0"border="0">

<tr>

<!-- This fixed Size is important. Without it, your d&d will not snapp-in -->

<tdstyle="width:200px;height:600px"></td>

<td>

<divid="imagePanel">

<imgid="dragHandler"src="smile.gif"alt="Smile!"/>

</div>

</td>

</tr>

</table>

<scripttype="text/xml-script">

<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">

<components>

<control id="imagePanel">

<behaviors>

<floatingBehavior handle="dragHandler" move="OnMove" />

</behaviors>

</control>

</components>

</page>

</script>

<scripttype="text/javascript">

function pageLoad()

{

Sys.Profile.set_autoSave(false);

Sys.Profile.loaded.add(onProfileLoadComplete);

Sys.Profile.saved.add(onProfileSaveComplete);

Sys.Profile.load();

}

function onProfileLoadComplete()

{

var objStyle = $object('imagePanel').element.style;

if (Sys.Profile.properties.poxTop !=null)

objStyle.posTop = Sys.Profile.properties.poxTop;

if (Sys.Profile.properties.poxLeft !=null)

objStyle.posLeft = Sys.Profile.properties.poxLeft;

}

function onProfileSaveComplete()

{

window.status ="Profile saved: " + Date();

}

function OnMove(sender, cancelArgs)

{

var ele = sender.control.element;

Sys.Profile.properties.poxTop = ele.offsetTop;

Sys.Profile.properties.poxLeft = ele.offsetLeft;

Sys.Profile.save();

}

</script>

</form>

</body>

</html>