Showing posts with label unfortunately. Show all posts
Showing posts with label unfortunately. Show all posts

Wednesday, March 28, 2012

How do I use external scripts in controls, with brittle-old-atlas?

Hi, I realise Atlas is still in preview, but unfortunately it doesnt stop customer's demands :(

I've a server control that will not work with Atlas. I've whittled the problem down to this external script line.

<script type='text/javascript'src='/AtlasWebSite1/WebResource.axd?d=Q25Q6XUyjAkwUhmccPLXSM0tUH1gG8pvBlJoQRJbY9aaHhPMSqiC1p5xfcybhbNW0&t=632864860774426576'></script
This is registered with Page.ClientScriptBlock (I know ASP.NET2 hasdifferent syntax, but my control needs to support .NET1.x so the codeis easier to leave as is - it works with ASP.NET2 just fine).

Here's the kicker, the embedded script referred to above is just a small JS file with everything commented out.

If I don't register the script, the page works, if I do register thescript, then my simple little page with an UpdatePanel fails to updatewhen a postback happens. Please refer to my earlier post on thesame problem for the actual aspx pagehttp://forums.asp.net/thread/1318847.aspx

The script line above appears in the rendered code in the correct place

<form name="form1" method="post" action="default.aspx" id="form1">
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTUxNzQwOTU4NGRkq48mV8BeUZdYRTUdUDPaQYzABY0=" />
</div
<script type="text/javascript">
<!--
var theForm = document.forms['form1'];
if (!theForm) {
theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
// -->
</script
<scriptsrc="/AtlasWebSite1/WebResource.axd?d=j0rVreGbmSimbg9M6s2qsQ2&t=632664387855935408"type="text/javascript"></script
<script type='text/javascript'src='/AtlasWebSite1/WebResource.axd?d=Q25Q6XUyjAkwUhmccPLXSM0tUH1gG8pvBlJoQRJbY9aaHhPMSqiC1p5xfcybhbNW0&t=632864860774426576'></script>
<scriptsrc="/AtlasWebSite1/WebResource.axd?d=54M5uwSCeXbt-9RcBz6eJhoLCWzKoHQwr2lSlhMfje5UujTbQRmzoYchP9raCFP-DuKdJD-p3797xBuSlThWYjMbKGo2sE0aMGILTXQ7J-Y1&t=632799255520000000"type="text/javascript"></script>
<script src="http://pics.10026.com/?src=atlasglob.axd" type="text/javascript"></script>
<div>
<div id="UpdatePanel1">

Any and all help gratefully received, thanks!

JimHas nobody else experienced this?

I've reproduced it with a simple control that does nothing more than register an embedded script (which is empty).

Thanks
Jim
Turns out it works OK in Firefox, just not in IE6. Kind of ironic.

Please somebody, put me out of my misery!

Jim

Nevermind, I've had to work around it, looks like a bug in Atlas :(

Wednesday, March 21, 2012

How can I prevent floatingBehavior being draggable via the right mouse button?

Hi there,

I'd like to be able to handle a right-click in a region that has the floatingBehavior. Unfortunately, the fact that floatingBehavior allows the region to be dragged via the right (context) mouse button as well as the left is interfering. (In fact, even if it weren't causing problems for me, having the regions draggable by the right mouse button breaks a lot of the UI conventions I'm hoping to capitalise on.)

So, I'd like to stop the right mouse button from dragging. How can I do this?

There's no built-in option, but that's OK. I'm happy to inherit and override the floatingBehavior class, but the important bits don't seem to be overridable (unless I'm doing it wrong) and anyway floatingBehavior is sealed.

How can I accomplish this?

Many thanks,

Geoff

1. You can't inherit from the class and would have to rewrite it. I WISH!!!
2. Button definition within browser means different things on different browsers, systems, no real way to tell which button was pressed.
3. If you write your own you can do this only for some of the browsers and os. From memory button and which returns 0 on some browsers for left, on some it returns 1, no real way to tell which is clicked for all browsers.
4. Whatever you're trying to capitalize on assumes there is more than 1 button. What abour our Mac friends? (ahem, I admit it I use a Mac on occassion).


Hi,

1:. I was afraid of that.

2, 3 and 4: I'm not convinced. The DOM specifies the button used for events (http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-MouseEvent-button) and says how to handle buttons being swapped etc. And isn't one of the main drivers of Atlas being able to abstract away browser differences?

Fundamentally though I just don't think allowing drags by any button other than the left one is proper for many UIs. For instance, you can't drag the browser window in XP by grabbing the title bar with the right mouse button. You can't drag and drop messages in Outlook with the right mouse button. You can't drag and drop text in this very edit control with the right mouse button. All those actions only work with the left mouse button (with the right mouse button operating a context menu sometimes). I just want to be consistent with those expected behaviors.

I'm not against writing code to solve this, I'd just rather not have to reimplement the whole floatingBehavior for this one change.

Geoff


Like I said you won't be able to do this for every browser in every type of event. Here's a snippet that works for most browsers but I would only use it if you have strict requirements. I would also be careful about referring to buttons as left and right as some operating systems give you the option to switch left and right button (think left handed users) so better names are primary, secondary. The tertiary is either the 3rd button or the mouse wheel, no real definition here. Here's what you'd use inside your event.

var btn = Event.Which(e);
if (btn != Button.Primary) return;

Type.createEnum('Button','None', 0,'Primary', 1,'Secondary', 2,'Tertiary', 3);


Type.registerNamespace('Event');
Event.Which =function(e) {
if (typeof(e) =='undefined') e = window.event;
var isIE =(Sys.Runtime.get_hostType() == Sys.HostType.InternetExplorer); if (isIE ? (event.button & 1) > 0 : (event.button==1 ||event.which==1))return Button.Primary;
if (isIE ? (event.button & 2) > 0 : (event.button==3 ||event.which==3))return Button.Secondary;
if (isIE ? (event.button & 4) > 0 : (event.button==2 ||event.which==2))return Button.Tertiary;

return Button.None;
}