how can I controls the position of the user control

I add the user control to the web form dynamicly!so it's hard to control the position,although i can do like this:

UserControl c = (UserControl)LoadControl("test.ascx");
  Panel p = (Panel)c.FindControl("panel1");
  p.Style["left"] = "140";


however it's too hard to control the position.

can anyone give me any better solution?

thanks verry much!!!

I love .net
5/8/2005 5:59:19 PM 93655 articles. 5 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 40

You may define a container on your page and then dynamically add the usercontrol to the already positioned container. For example, in your code:

  UserControl c = (UserControl)LoadControl("test.ascx");

on your page, you have Panel1 defined inside a table:

<table border="true">
<tr><td>Your usercontrol: </td>
<td><asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px"></asp:Panel></td>

The control will be added to the 2nd cell.

5/8/2005 10:54:51 PM


  i had done what you said, that's the question what i need to help

  Panel p = (Panel)c.FindControl("panel1");
  p.Style["left"] = "140";

I love .net
5/9/2005 1:20:15 AM

So you're asking how to control the position of controls inside your usercontrol? I assume the control's position also need to be changed dynamically depending on the aspx, otherwise, you should just position it properly in the usercontrol.

To do this dynamically, a better way is to expose some properties on usercontrol. In the user control, you could do whatever you like depending on the property value. On the page, you could declare the control like this:

<MyTag:MyUC id="uc1" PanelLeftPosition="140" runat="server" />

Or, if you load it programatically, you can put code:

MyUC c = (MyUC)LoadControl("test.ascx");

Does that help?

5/10/2005 12:57:57 AM
thanks for your reply,let me have a try
I love .net
5/14/2005 1:32:39 AM

Similar Artilces:

access controls on web user control x from web user control Y
I have 2 web users controls in a page and I would like to get or set the selected values of a few dropdown boxes on web user control X from web user control Y and I also would like to know how to access functions that are on a web user control X from a web user control Y, is this possible? How can I do it? User can access and set the values of the User Control from .aspx page through properties,using javascript and in code-behind of aspx page.The details of it are shown below Using PropertiesIf the Sample.ascx control has two textboxes and submit button.You can access the valu...

Web User Control to Web User Control...
Hi, I have 2 User controls on a page and want Control1 to call a method of Control2. Is this Possible? Example: Con1 = Datalist showing products, each with a Quantity Box and a Button. Con2 = Repeater showing Cart Preview (name, Price) in page.aspx. When I click on the button on the DataList in Con1 it adds the item into the Session based Cart. However it does not update the Cart Preview. I need to call BindPreview() in Con2 in order to update the Cart Preview... Does that make sense? argh! any help much appreciated! PeteWeb Design Nottingham, UK Well I can call BindPreview() from m...

How to access individual controls from a form containing the web user control containing those controls
 Below is a block of code in my .aspx form named default.aspx. In this form I load a web user control. I then add it to a place holder control.(Lines 3 and 4 below) So how do I access the individual controls in my web user control? I want to set the properties on those controls, but I am baffled as to how to access the control. For example I have a text label control named "label3". How do I access this control. Because for example, under certain situations I want to hide that control. ( Label3.Visible = false;)  1    if(!Page.IsPostBack) 2&nb...

(How) Can i use the form elements of a user control from another user control???
Hi, i have a user control with 4 other user controls. Actually i have 4 panels and each user control is inside a panel. Its like a 4 page form which are all connected to each other. Is it possible to have access to web controls that i have in my user controls from the main user control. In my main user control i have a submit button and a tab list. User can browse through the tabs and each tab is bound to a panel. so clicking on tab1 makes panel1 visible which holds the first user control, second tab makes second panel visible and the rest invisible and the second panel holds the ...

How can find a control in the Web User Control
<uc1:Ctrl_Makes ID="Ctrl_Makes1" runat="server" /> The Web User Control has the TextBox which is following:<tr><td class="formtxt"> <asp:Label ID="lblAvailabilityOpt" runat="server">Asking Price</asp:Label></td> <td align="left" height="28" width="74%"> <asp:TextBox ID="txtPrice" runat="server" CssClass="field1"></asp:TextBox> </td></tr>   For example an Default.aspx page contain the following Web Us...

Problem in accessing web form data in user controls when create user control dynamically
HI. I have a problem using web user control. I designed a user control named NewsForm. This user control contains some web form elements like <asp:textbox>. When I add it in an .ASPX page, all things may be true. I can know which user filles in textbox (for example and other controls) <%@ Register TagPrefix="uc1" TagName="NewsForm" Src="NewsForm.ascx" %> and <UC1:NewsForm id="newsForm" runat="server"></UC1:NewsForm> But when i create it in code behined dynamically, however user control has web form controls but their value are blank for example //aspx co...

web controls and web user control
i have a problem in a web form , I have a webform that contains a web user control which in turn contains a html input form ,the web control events don't fire up ,When I click button ,no effect ,I don't know what is the effect of the html form which is in the web user control on the web controls in the web form ?? can any one help me the web control event should be handle in the code behind page, is the event handler for the button you are clicking registered? You can try double clicking the button, should give you the default btn_click event handler in code behind. Also, make ...

Adding User Controls from Sting can the User Control contain a CompileWith Control directive?
I want to store my User Controls in a DB. So I working with ParseControl and passing it a string. However when I pass as string of a control with codebehind I get this error. My Code: Dim strControl1 As String = "<%@ Control Language=""VB"" AutoEventWireup=""false"" CompileWith=""Control1.ascx.vb"" ClassName=""Control1_ascx"" %>" & vbCrLf & "<div>Control 1<br /><asp:PlaceHolder ID=""Control1PlaceHolder"" Runat=""server""...

UpdatePanel within a web user control resets data of controls outside the user control
Hello, I have a usercontrol on my page which displays a running marquee text. It makes use of an UpdatePanel (within the user control) to refresh the marquee text (within the updatepanel) at periodic intervals. For this I added a timer control and its tick event as an async postback trigger for the UpdatePanel. I have a lot of textboxes and dropdown list boxes (all with runat=server) on the page outside the above user control. These are also contained in different UpdatePanels. Problem is, when the user control does a postback to refresh the marquee text, it causes some of...

User Control Within UserControl
If I have a user control A and then inside it a user control B embedded/referenced within it.  User Control A has a panel defined (cpeNewUser) that I want to manipulate from the code behind of User Control B based on some event that happens.So putting this in my code behind of User Control B won't work as it has no idea of cpeNewUser:cpeNewUser.Collapsed = true;So is it because only at runtime they are married up and because of this you cannot access each other's objects at compile time?  How would I get this to work becuase I'm using all user controls inside a AJAX Too...

Persisting data in a web user control, which contains a list of other web user controls.
 Hi All, I have a control I've created, which can have a number of child controls - also user controls - stored as an ArrayList, which can be added wither a design time or programmatically.My problem is when I add to the list programmatically, it doesn't persist them. So if I add 3 child controls in step 1 of a wizard, with the aim that those three will be visible inside the parent in step 3, what happens is that the parent has no child controls and the item count is 0.Can anyone help? Thanks in advance.Code:Parent Control Markup: <%@ Control Language="C#" Auto...

Controlling web control instances on Web Form
I have created a composite control, extending functionality of the Hidden Control. However, I would like to prevent the user from adding this control to the page multiple times. I only want one instance of the control on the Web Form. What setting in my project to I adjust to enable this functionality? I can not find it in any of the books that I have referenced. Is this a setting or is this code that has to be added to the inheriting class. Looks like there is no standard apporach. But I'd consider using static field to count number of created objects and throw exception if second object ...

Is there any web form control that can work as IFRAME html control?????
in html pages, we can use iframe control in which we can load another pages and/or folder explorer. now, i'm developing a web page in which i like to show the folder explorer when user clicks a link. as a prototype, i developed an html page like below: <html> <head><title>Using iFrame to browse a folder</title> </head> <body bgcolor=cyan> <table left=5px top=5px id=tabMain width=90% height=90% border=1 cellspacing=1 cellpadding=1> <tr height=100%> <td width=20% align=center valign=middle> <INPUT TYPE="Butto...

multiple user control into a web form (how do I keep the status of each control?)
A user control implements a quiz.The control has a property (id_question) to choose the different question the user control have to display. The user control have another property, its STATUS (status = 1 mean to show the question, status=2 means to show a message to the user that have answered the question). In the user control there is a button, clicking the button to answer the question cause the control post the form and call a DB and register the answer. During Postback, in page_load method of the user control I change the status from 1 to 2 (from show quest...

Web resources about - how can I controls the position of the user control -

Control - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Home lost after out-of-control grassfire at Edgecombe in central Victoria
One home is lost after a fast-moving grassfire sweeps through Edgecombe in central Victoria..

Apple’s iOS 9.3 preview page hints at possible Control Center toggle to enable Night Shift
... If you head to the iOS 9.3 preview page on Apple Canada’s website , you can see that there’s an option to enable Night Shift from Control Center ...

#TBT: The Time Ad Age Went All-In for Gun Control
"Can there be any doubt anywhere that violence and contempt for law and order are doing their rotten best to tear American society apart? "Can ...

New Night Shift mode in iOS 9.3 could have its own Control Center toggle
In all likelihood, youll be able to toggle the new Night Shift mode in iOS 9.3 right from Control Center. It came from Canada At least thats ...

Simple free app alerts you when a program (or hacker) takes control of your webcam
... can take over your webcam without you knowing about it. That's right, malware, hackers or even government agencies like the NSA can take control ...

Cruz control: take a look at his puppet master
Cruz control by digby If you read nothing else today, read this Bloomberg article about Ted Cruz's top benefactor, the certifiably looney tunes ...

Run on Italy's Third Largest Bank? Capital Controls or Bail-Ins Next? Why Take Chances?
... "brilliant" comeback? Not a single fundamental problem with Italy, the ECB, the euro, or Europe in general has been fixed. Capital Controls ...

AlunaGeorge share "I'm In Control" ft. Popcaan
... last year to preview material off the followup to their 2013 debut Body Music, and now the first single is here. It's called "I'm In Control" ...

A guy made a remote control airplane using the fan from an old wall heater
... and old heater in his house when he realized that the blower motor inside of it could work a lot like a jet engine — so he made a remote control ...

Resources last updated: 1/21/2016 10:09:54 PM