473,414 Members | 1,632 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,414 software developers and data experts.

How to change the user control or HtmlTable position at runtime?

Leo
I created a user control which is some text contained in a HtmlTable.
I put this control into main form. I would like to have the ability to
move this control around in the main form. I think one way to do this
is to change the style of this control at runtime ("Left:xx px; Top:xx
px"). Another way is to move the HtmlTable in the control (i.e. change
the style of it). However I couldn't figure out how to let it work. At
design time, I changed the style of the control (Top: 100px). However
at runtime, the contrl still goes back to the original location(Top :
100px). Any suggestion? Thanks in advance.

Leo
Nov 19 '05 #1
1 4751
Hi Leo,

I hope I understand what you need to do... anyway here goes.

Let's say this is the content of your usercontrol with the table called
txtmove.ascx:

<%@ Control Language="vb" AutoEventWireup="false"
Codebehind="txtmove.ascx.vb" Inherits="p4320work.txtmove"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<table runat="server" id="Table1" style="LEFT: 200px; POSITION: absolute;
TOP: 100px" cellspacing="1"
cellpadding="1" width="300" border="1">
<tr>
<td>This is the text</td>
</tr>
</table>

You add the user control to your .aspx page so it looks like this:

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="usetxtmove.aspx.vb" Inherits="p4320work.usetxtmove"%>
<%@ Register TagPrefix="uc1" TagName="txtmove" Src="txtmove.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>usetxtmove</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<uc1:txtmove id="Txtmove1" runat="server"></uc1:txtmove>
<asp:button id="Button1" style="Z-INDEX: 101; LEFT: 48px;
POSITION: absolute; TOP: 72px" runat="server"
Text="Button"></asp:button>
</form>
</body>
</html>

Notice that the positioning is GridLayout, not flow.

In the code behind, get a reference to the UserControl and within that
reference, get a reference to the table ("Table1").
With the reference, change the table's style attribute to use absolute
positioning, giving it the new coordinates.

Private Sub Button1_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim usrcntrl As UserControl
Dim tbl As HtmlTable
usrcntrl = Page.FindControl("Txtmove1")
If Not IsNothing(usrcntrl) Then
tbl = usrcntrl.FindControl("Table1")
If Not IsNothing(tbl) Then
tbl.Attributes.Item("style") = "LEFT: 400px; " & _
"POSITION: absolute; TOP: 200px"
End If
End If
End Sub

When you click the button, the table should jump to the new position.

Does this help?

Ken
Microsoft MVP [ASP.NET]
Toronto
"Leo" <pk*******@yahoo.com> wrote in message
news:81**************************@posting.google.c om...
I created a user control which is some text contained in a HtmlTable.
I put this control into main form. I would like to have the ability to
move this control around in the main form. I think one way to do this
is to change the style of this control at runtime ("Left:xx px; Top:xx
px"). Another way is to move the HtmlTable in the control (i.e. change
the style of it). However I couldn't figure out how to let it work. At
design time, I changed the style of the control (Top: 100px). However
at runtime, the contrl still goes back to the original location(Top :
100px). Any suggestion? Thanks in advance.

Leo


Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Christian | last post by:
Hi, I try to change the position of a WebUserControl on my WEbform (layout is set to GridLayout) by changing the absolute position in the html-code but it does not work. When I change the...
1
by: Yannis CORRE via .NET 247 | last post by:
Hello, I have two questions : 1 - I want to generate dynamically a personnalized table from a dataset. I want to create each of my rows and columns. So, I use a HtmlTable and I build my Table...
2
by: Alfred Salton | last post by:
Can anyone show me how to set the css class of an HtmlTable control in code on the server? I can't find any indication that the css class is a property of the HtmlTable, HtmlTableRow and...
3
by: Al Wilkerson | last post by:
Hey, I have a Web Form with a drop down list, textbox, and search button. When click the search button an SQL server database is queried fordata. Once I have the data in a dataset I use the...
1
by: Al Wilkerson | last post by:
Hey, I have a Web Form with a drop down list, textbox, and search button. When click the search button an SQL server database is queried fordata. Once I have the data in a dataset I use the...
20
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just...
3
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for...
1
by: =?Utf-8?B?Tmlrb2xheSBQb2Rrb2x6aW4=?= | last post by:
Goon afternoon, Community! I'm sorry for a post in wrong place, but couldn't find more appropriate place for that. Could you be so kind and help me with dynamic creating controls in asp.net....
1
by: brettokumar | last post by:
hi I want to know how to change the position of the web controls at runtime relative to some other control. by user like bbc.co.uk wat i hav to do for that plz share ur ideas
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.