response.write()处于特殊位置

时间:2011-03-16 11:08:28

标签: asp.net

x:100
y:400

我喜欢

response.write("test");

x,y special ;

在x:100和y:400写测试页面

1 个答案:

答案 0 :(得分:2)

这样做的好方法

我看到你想在坐标位置写Test。你可以这样做:

<asp:Panel runat="server" id="TestPanel" visible="false">
    <asp:Literal runat="server" id="TestText" />
</asp:Panel>

然后在你的代码隐藏中:

int x = 100;    // Your X coordinate
int y = 400;    // Your Y coordinate

// Set the text of the panel (your response.write in effect)
TestText.Text = "Testing!";

// Set the style of the containing panel to position it to X and Y
TestPanel.Style["position"] = "absolute";
TestPanel.Style["top"] = y.ToString() + "px";
TestPanel.Style["left"] = x.ToString() + "px";

// Make the panel visible
TestPanel.Visible = true;

更快更脏的方法

如果你决定使用response.write,你可以这样做:

int x = 400;
int y = 200;
Response.Write("<div style='position:absolute;top:" + y.ToString() + "px;left:" + x.ToString() + "px'>Testing!</div>");