Jump to content
Xtreme .Net Talk

nima1985

Members
  • Posts

    20
  • Joined

  • Last visited

Everything posted by nima1985

  1. hey thanks for the link. :) I had another question: i have an image, which is of a class "drag". so i declared it in my html as follows: <asp:image id="Image1" style="Z-INDEX: 116; LEFT: 1216px; POSITION: absolute; TOP: 8px" runat="server" Width="80px" Height="24px" ImageUrl="\slider2.JPG" CssClass="drag"></asp:image> in the class "drag" written in javascript, is it possible to save the id of the specific image that is being dragged? (ie, there can be 10 images all using teh class drag. but i wanna save the id of the specific instance of the image which is being used at teh moment) is there anyway I can do that ? i tried to do place the following in the function that gets called after the image gets dragged: var n; n=this.id but that gave a value of "undefined" for n. i was able to save the location of the image however, so i know that the function is working properly. i just dont know how to save the instance's id. thanks again ;)
  2. it doesnt seem to be working.. here's my javascript code (exactly what you posted up): <script> function BtnWrite() { self.document.forms[0].elements[0].value=event.clientX; } </script> and here's the info on the button: <asp:Button id="testbutton" OnClick = "BtnWrite()" style="Z-INDEX: 135; LEFT: 992px; POSITION: absolute; TOP: 384px" runat="server" Height="40px" Width="72px" Text="Button"></asp:Button> the error that comes up is 'BtnWrite' is not a member of 'ASP.WebForm1_aspx'. :s i'm also confused about the javascript function: it saves the event.clientX btu only when the button is pressed. so how is the software suppose to know when the user drags the image (how are the drag class and the function above related?) because, it just gets the most recent event.clientX, and if the user drags the image, then clicks somewhere else before the program calls the BtnWrite function, the value will be incorrect.. Also, what is "self.document.forms[0].elements[0]" ? i think maybe im totally misunderstanding :s thanks again ;)
  3. I changed my javascript code to: <script language="JavaScript1.2"> <!-- var dragapproved=false var z,x,y function move(){ if (event.button==1&&dragapproved){ z.style.pixelLeft=temp1+event.clientX-x //z.style.pixelTop=temp2+event.clientY-y coordlabel.text=event.clientX <<<<<< return false } } function drags(){ if (!document.all) return if (event.srcElement.className=="drag"){ dragapproved=true z=event.srcElement temp1=z.style.pixelLeft temp2=z.style.pixelTop x=event.clientX y=event.clientY document.onmousemove=move } } document.onmousedown=drags document.onmouseup=new Function("dragapproved=false") //--> </script> on spot <<<< i tried to save the label's text to the coordinates, and made the label visible so i can see that it works. when i load the page, and move the image, the label's text never changes to the x coordinate :s
  4. Thanks for the reply Hyuga. :) What do you mean by "hidden field"? can you describe a lil bit more (maybe provide some example code)? Thanks again :D
  5. i thought about making images and hiding them until the user needs them, but i cant do that becuase the user can have a million images if they wanted. so it's better to create them as they're needed. creating new threads also causes a lotta probs if the user creates, lets say, a million images, coz that means a million threads :s if anyone knows how to access one variable from both asp/vb and javascript, it would be really great coz that's one possible solution :s until then, im sort of lost.. my application isnt that fancy :P but yea if i ever get it up online (get it approved by my supervisor, etc), ill definately put up a link. warning: by looking at my page, u can easily tell that I just started (at the beginning of this week) with asp.net and webpages in general :s thanks again to everyone (especially joe) :)
  6. hey joe the z-index thing worked :) for the IsPostBack "function" that ur talking about, how would i be able to get the coordinates of the image after the user moves it? (because when teh user moves the image, and places it somewhere, the function that is called is in teh HTML : if (event.button==1&&dragapproved){ z.style.pixelLeft=temp1+event.clientX-x return false } so how would I be able to save these values in a variable type, even tho it is in javascript? ie, it has to be a global variable that can be accessed by the asp code and the javascript, but HOW? :s thanks again ;)
  7. I GOT IT!! :D instead of deleting the line: y=event.clientY you have to delete the line: z.style.pixelTop=temp2+event.clientY-y :D me happy Oh but when i press another button, the image goes back to the original coordinates. Is there a way to keep it in the coordinates that the user moves it to? one more question (..sorry..): my image, when i drag it, it has to go on a grid. But when the user drags it on the webform, it goes behind the grid. is there anyway of making the image always on top of everything on the webpage (i cant seem to find a "priority" function.. should i use layers? and if so, how )? THANK YOU!!
  8. hey joe i deleted that line, but what happened was that, i want the bar to start at a certain position, and they can move it horizontally. when i deleted that line of code, as soon as i click on the image, it moves to coordinates (0,0) and i can then move it horizontally. but i want it to start at the coordinates i set in my WebForm1. as soon as i make the image, it shows up in the right coordinates, but when i click on it to move it, it goes up to (0,0) here's my code: in WebForm1: Dim i As New System.Web.UI.WebControls.Image top = 468 left = 50 i.ImageUrl() = "\slider2.JPG" i.CssClass = "drag" i.Style.Add("position", "absolute") i.Style.Add("top", top.ToString & "px") i.Style.Add("left", "80px") CType(Application("Slider"), ArrayList).Insert(Application("RadioCount"), i) PlaceHolder1.Controls.Add(CType(Application("Slider"), ArrayList).Item(i)) in my HTML: same thing as before but without the line: y=event.clientY how can i fix this now ? :s
  9. hey joe and utilitaire thanks so much for the replies :D i ended up solving both issues actually (found a lotta good sites online that provide code) 1) use an arraylist, but must cast in the WebForm in order to use arraylist functions: in Global.asax: Dim list as New ArrayList Application("list")=list in WebForm1.aspx.vb: CType(Application("list"), ArrayList).Insert(0, label1) and for 2) create a new object in asp.net, and in the HTML, after <HEAD> put: <HEAD> <style>.drag { CURSOR: hand; POSITION: relative } </style> <script language="JavaScript1.2"> <!-- /* Drag and Drop Script- © Dynamic Drive (http://www.dynamicdrive.com) For full source code, installation instructions, 100's more DHTML scripts, and Terms Of Use, visit dynamicdrive.com */ var dragapproved=false var z,x,y function move(){ if (event.button==1&&dragapproved){ z.style.pixelLeft=temp1+event.clientX-x z.style.pixelTop=temp2+event.clientY-y return false } } function drags(){ if (!document.all) return if (event.srcElement.className=="drag"){ dragapproved=true z=event.srcElement temp1=z.style.pixelLeft temp2=z.style.pixelTop x=event.clientX y=event.clientY document.onmousemove=move } } document.onmousedown=drags document.onmouseup=new Function("dragapproved=false") //--> </script> and right after the asp: declaration, put "class=drag": <asp:image class="drag" id="Image1" ></asp:image> So utilitair, ur right for 2), it needs javascript :) One more question: for 2), i actually wanted a slider bar thingy that the user can move horizontally. My image that i made using the above solution, the user can move it around anywhere on the page. adn I want to restrict that to only horizontally. Does anyone know any websites that show how to do that? thanks again :)
  10. Hi, I am making an ASP.NET web form for the first time, and I have a few questions: 1) How do you make global array variables? I know that you can make global variables such as: Application("end")=end in your Global.asax's Application_Start (..) and access it in ur Page_Load: Application("end")=false but for arrays, how do you declare it and call it? 2) How do you allow for the user to move an object on the page? (ex: if the user is allowed to move an icon around the page to wherever they would like)? Also, how would you restrict the user to only move horizontally (or vertically)? Thank you SO much in advance for any help. :)
  11. I declared them in vb.net right before the GPS637Time(..) function. Dim time, week as Single I even tried to create new objects with time and week but it still created the error: time = new Single week = new Single
  12. Thanks for the reply. I made "ok" be an Integer, and I made the declaration for the function return an Integer. It still causes the error. I think it might have something to do with the parameters. I tested the c++ code using just c++, and sending pointers to the function. I think the way I send variables in vb.net is incorrect. :s I'm not sure wut to do next.. How else can i send the variables in vb.net?? :confused:
  13. Hi, I have c++ code which I wrapped (so it's being used as a dll), and I call the functions in vb.net. The C++ code calls functions (which work, coz I tested it in other programs) from a PCI card hooked up to the CPU. In C++ the function which I call is: extern "C" __declspec( dllexport ) int _stdcall GPS637Time(float *time, float *week) { UCHAR getpacket[80], sendpacket[80]; // Receive buffer GpsPkt receive; GpsPkt send; int n; int s; send.len = 1; send.id = 0x37; send.data =sendpacket ; receive.len = 20; receive.id = 0x41; receive.data = getpacket; s = bcGPSMan (&send, &receive); for (n=0;n!=100;n++){ if (s!=RC_ERROR) break; s = bcGPSMan (&send, &receive); } if (s == RC_OK) { *time = (float)(convertf(&getpacket[0])); *week=(float)(convertf(&getpacket[4])); return RC_OK; } return RC_ERROR; } bcGPSMan(..) is from the PCI card. the helper function is: float convertf (char *s) { union { float f; char uc[4]; } fconv; fconv.uc[3] = *(s++); fconv.uc[2] = *(s++); fconv.uc[1] = *(s++); fconv.uc[0] = *s; return fconv.f; } In VB.NET, I declare the dll function: Private Declare Function GPS637Time Lib "GPS637Wrapper.dll" (ByRef time As Single, ByRef week As Single) As Long And call it: Dim ok As Long ok = GPS637Time(time, week) Where I get the above error message. Can ANYONE pleaseeeeeee help me? :-\ Thank You!! :)
  14. thanks for the reply. just making sure its "do-able" before I spend time writing up the code. :D
  15. Hi, I wanted to create multithreads in c++ and use it in VB.NET, so I was thinking that I can wrap the c++ code and use it in VB.NET (like any other dll). I have a function (functionexample()) in c++ that creates another thread (which is linked to another function, interrupt()). So I wanted to expose functionexample() in vb.net. Is all this possible ? :confused:
  16. hey, thanks again for ur help. I'll see if this code is ok for dll's (coz I have to expose the functions written in c++, in vb.net, by using libraries). Anyways, thanks again. :D
  17. hey, thanks so much for the reply. I ended up multithreading, and so I sort of used a polling technique (my main reason why i didnt use polling before was that i wanted to be able to call other functions and do other things at the same time as the timer). So multithreading seemed to be the best way. Also, thanks for the info on how to raise events in c++. If I wanted to "catch" the events in VB.NET, would you know how I can do that (what would be the syntax in vb)? (I'm planning on wrapping the c++ code and using it as a dll in vb.) Thanks again ;)
  18. Hi, I am having some trouble with interrupt handling. I have a device which sends me an interrupt every 5 seconds, and I need my code (using either VB.NET or c++) to respond to the interrupt as soon as it is fired. Is there anyone who would know how to do that ? Thanks :-\
×
×
  • Create New...