网页上移动图像 [英] moving image on webpage

查看:121
本文介绍了网页上移动图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是这个解决方案有可能在asp.net http://stackoverflow.com/questions / 1086989 /拖拽,图片框,里面-的WinForm上运行时

is this solution possible in asp.net http://stackoverflow.com/questions/1086989/dragging-picturebox-inside-winform-on-runtime

我只是想能够在一个WebForm左右移动图片

i just want to be able to move an image around on a webform

推荐答案

您引用的问题写在窗口的形式。你不能drag'n拖放在您的网页表单元素在Windows窗体。

The question you referenced is written in windows forms. You can not drag'n drop elements in your web form as in windows forms.

如果您想拖,并在Web应用程序拖放元素,你应该使用客户端代码。

If you want to drag and drop elements in a web application, you should use client side code.

在客户端的最佳选择是使用一个库,而最好的是的 JQuery用户界面的在我看来。 在演示我联系用户可以拖动一个div元素。这里是一个静态图像和服务器端ASP.NET控件一个简单的拖放例如:

The best option in client side is to use a library, and the best one is JQuery UI in my opinion. In the demo I linked user can drag a div element. Here is a simple dragging example with a static image and a server-side ASP.NET control :

<head runat="server">
    <script src="js/jquery-1.3.2.min.js" language="javascript" ></script>
    <script src="js/jquery-ui-1.7.2.custom.min.js" language="javascript" ></script>
    <script type="text/javascript">
        $(function() {
    	    $("#draggable").draggable();
    	    $("#<%= imgServerControl.ClientID %>").draggable();
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <!-- Static Draggable Image -->
    <img src="ac-dc.jpg" id="draggable" />

    <!-- ASP.NET server image control -->
    <asp:Image ImageUrl="ac-dc.jpg" ID="imgServerControl" runat="server" />
    </form>
</body>
</html>

注意::要测试此代码,所有你需要做的是下载 JQuery用户界面与拖拽组件中的从这里并把它添加到你的脚本文件夹中。

Note : To test this code, all you need to do is to download the JQuery UI with draggable component from here and add it to your script folder.

这篇关于网页上移动图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆