473,383 Members | 1,885 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How to bound a specific div to another div?

i have made a draggable panel using ajax tool kit web developer 2008. All i need to do is to bound a draggable div tag to another div`s boundary. That is, to check everytime it gets dragged whether its in boundary or not. If is in, then ok else canel that drag.



heres my code:
Expand|Select|Wrap|Line Numbers
  1. <!-------------Draggable Panel-start--------------!-->
  2.             <div id="Photo" style="width: 50%; height: 50%;">
  3.             <cc1:DragPanelExtender ID="DragPanelExtender_Photo" runat="server" TargetControlID="PanelContainer" DragHandleID="PanelHeader">
  4.             </cc1:DragPanelExtender>
  5.  
  6.             <asp:Panel ID="PanelContainer" runat="server" CssClass="Draggable_Panel_Box" BackImageUrl="~/Images/Photo.png">
  7.                     <asp:Panel ID="PanelHeader" runat="server" CssClass="Draggable_Panel_Header_PHOTO">
  8.                     My Photo<hr />
  9.                     </asp:Panel>
  10.                     <asp:Panel ID="PanelBody" runat="server" CssClass="Draggable_Panel_Content_PHOTO" HorizontalAlign="Center">
  11.                         <img src="Images/a.jpg" alt="" style="max-height: 140px; max-width: 203px;"/></asp:Panel>
  12.             </asp:Panel>
  13.             </div>
  14.             <!-------------Draggable Panel-end----------------!-->
  15.  
  16.  
  17.             <!-------------Draggable Panel-start--------------!-->
  18.             <div id="ScrapBook" style="width: 50%; height: 50%;">
  19.             <cc1:DragPanelExtender ID="DragPanelExtender_ScrapBook" runat="server" TargetControlID="Panel1" DragHandleID="Panel2">
  20.             </cc1:DragPanelExtender>
  21.  
  22.             <asp:Panel ID="Panel1" runat="server" CssClass="Draggable_Panel_Box" BackImageUrl="~/Images/scrapBook.png">
  23.                     <asp:Panel ID="Panel2" runat="server" CssClass="Draggable_Panel_Header_SCRAPBOOK" Width="340" Height="26">
  24.                     Catalog<hr />
  25.                     </asp:Panel>
  26.                     <asp:Panel ID="Panel3" runat="server" CssClass="Draggable_Panel_Content_SCRAPBOOK" HorizontalAlign="Center" Width="340" Height="255">
  27.                         <asp:Label ID="Label" runat="server" Text="Hi, this is Saad Khan.  Currently working on web programming project. INSHALLAH this project will be a benchmark for others in university. INSHALLAH :)" style="max-height: 200px; max-width: 220px;" Height="220" Width="220"></asp:Label>
  28.                     </asp:Panel>
  29.             </asp:Panel>
  30.             </div>
  31.             <!-------------Draggable Panel-end----------------!-->
Oct 3 '08 #1
2 2109
pronerd
392 Expert 256MB
Sorry I do not have time to provide a more detailed response to this.

You need to do the following.

1. Set an onMove or onMouseUp event on the layer being dragged that will call your JavaScript logic to check to see if they over lap

2. When the event fires you want your java script logic to get four values from the layer being dragged, and the layer it is going to be checked against. Those values are X, Y, width, and height.

3. Then take the values from the layer being compared to and add the X to the width, and add the Y value to the height. The X value will give you the starting position on the X-Axis, and the X + width will give you the X-Axis ending position. The same thing is true on the Y-Axis. Y will be the starting point, and Y + height will be the ending point.

4. Then take the four values from the layer being dragged and run four tests. If any of these are true then the layer that was dragged is over lapping the layer it is being compared to.
a. If the dragged layers X value is greater than the other layers X value and less than the other layers X + width values.
b. If the dragged layers X + width value is greater than the other layers X value and less than the other layers X + width values.
c. If the dragged layers Y value is greater than the other layers Y value and less than the other layers Y + height values.
c. If the dragged layers Y + height value is greater than the other layers Y value and less than the other layers Y + height values.

NOTE: To get reliable values X, Y, Width, and Height values the position attribute for the layer needs to be set to absolute.
Oct 3 '08 #2
acoder
16,027 Expert Mod 8TB
Or set it relative to the parent div and not allow it to exceed the x+width and y+height boundaries.

Saadkhan, for the code to be of much use in this forum, please post client-side code, not .NET code.
Oct 4 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Aaron Ackerman | last post by:
I am using typed datasets in an N-Tier Windows app using VB.NET. I know this posting cannot be fully explained in a single post that is why I am asking for someone to point me to a real world...
12
by: Russell E. Owen | last post by:
I have several situations in my code where I want a unique identifier for a method of some object (I think this is called a bound method). I want this id to be both unique to that method and also...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
14
by: Abhi | last post by:
FYI: This message is for the benefit of MS Access Community. I found that this prblem has been encounterd by many but there is hardly any place where a complete solution is posted. So I thought...
7
by: vsiat | last post by:
I am trying to create a treeview out of a database table with the typical structure ID, NAME, PARENTID, TYPE, EXTRA_INFO, where is linked to the . What I want to achieve is create a tree made...
4
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box...
8
by: Jon Weston | last post by:
I'm setting up an Access2003 database with pictures. I put a bound ole picture ctrl on a form that's source is the table that contains the pictures and follow ALL the directions for embedding a...
6
by: Welie | last post by:
I am having a problem an it's driving me crazy, I hope someone can correct my technique. I can't find a pattern and don't know where to look to debug this. The problem is on a continuous form, the...
4
by: sklett | last post by:
(I posted this in a databinding NG, but it's a VERY low traffic NG so I thought I would post here as well. I hope no one minds too much, if you do I'm sorry) I have a DGV that is bound to a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.