c# asp.net 控制控件的坐标位置,更改控件坐标,后台改变前台CSS样式,top,left

前台

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FPSZ.aspx.cs" Inherits="FPSZ" %>

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

<script language="JavaScript" type="text/javascript" src="../../js/Move.js"></script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<div>
<asp:Label ID = "lblTKRQText" Text = "黑色头发" runat = "server" name="label" BackColor="Silver" Style="left: 100px; position: relative;top: 200px" Width="104px"></asp:Label>

<asp:Label ID = "lblMC" Text = "紫色头发" runat = "server" name="label" BackColor="Silver" Style="left: 300px; position: absolute;top: 240px" Width="113px"></asp:Label>

<asp:Label ID="Label3" runat="server">黑色头发的默认坐标值为left:100px; top:200px</asp:Label><br />
<asp:Label ID="Label4" runat="server">紫色头发的默认坐标值为left:300px; top:240px</asp:Label><br />
<asp:Label ID="Label1" runat="server" Text="left的值:"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server">200</asp:TextBox>
<asp:Label ID="Label2" runat="server" Text="top的值:"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server">100</asp:TextBox>
</div>
<br />
<div>
 <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="改变黑色头发的位置" />
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="改变紫色头发的位置" /></div>
</div>
</form>
</body>
</html>


后台

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class FPSZ : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
//lblTKRQText.Style["Style"] = "left: 385px; position: absolute;top:189px";//设置lblTKRQText控件的样式

lblTKRQText.Style["Style"] = "position: relative;top:" + TextBox2.Text + "px;left: " + TextBox1.Text + "px";//设置lblTKRQText控件的样式
}
protected void Button2_Click(object sender, EventArgs e)
{
//lblMC.Style["Style"] = "left: 385px; position: absolute;top:189px";//设置lblMC控件的样式

lblMC.Style["Style"] = "position: absolute;top:" + TextBox2.Text + "px;left: " + TextBox1.Text + "px";//设置lblTKRQText控件的样式
}
}


黑色头发:http://heisetoufa.iteye.com/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值