(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 second user control. Each user control is made of form elements. when i click the submit button from the main user conrtol (or say web form) i want to be able to get all values from every form element i have in my user controls. Is this possible?

I can insert the actual form design in each panel but it makes the page look real complicated so i wanted to use a seperate user control for each panel. textbox1 in usercontrol2 is not defined in my main user control so i cant use textbox.text. I wonder if there is a way to inherit other  user control elements in the main one.

thanks in advance,
-shane
 
0
e106199
6/22/2005 6:49:30 AM
asp.net.web-forms 93655 articles. 5 followers. Follow

4 Replies
991 Views

Similar Articles

[PageSpeed] 17

Try to change the elements in the user controls from protected to public like this:
public System.Web.UI.WebControls.TextBox textbox;

And declare the user controls in the main control like this:
protected WebUserControl1 webUserControl1;
protected WebUserControl2 webUserControl2;
protected WebUserControl3 webUserControl3;
protected WebUserControl4 webUserControl4;


Some words about .Net programming.
0
Royhwa
6/22/2005 11:21:26 AM
An then call the textbox1 as webusercontrol2.textbox2 right? 

Is there a way to tell visual studio to use public instead of private for every item i drop in the page? Or should i change them manual?
thanks,
-shane

0
e106199
6/22/2005 1:56:11 PM
I did it what you said but i m getting the following error. 
Object reference not set to an instance of an object.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
usercontrol2.Label1.Text = "hello world"

End Sub


Here is more information about what i do. I have a tab control with 5 tabs. Clicking a tab makes a panel visible which holds a user control. so there is always one panel (one user control) visible in my page. I want user to browse through each tab, fill any form he wants and hit the submit button at the end. The tab,panels and the submit button is in my main page (say main.aspx). So when the user clicks submit i should have access to all textboxes, radio buttons, checkboxes in other user controls.

In the above code i tried to set the text property of label1 (in my second user control) to "hello world" but got the error.
And here are my declarations:
Protected usercontrol1 As  usercontrol1
Protected usercontrol2 As  usercontrol2

and here is how my label1 is declared in usercontrol2
Public WithEvents Label1 As System.Web.UI.WebControls.Label

Any help will greately be appreciated,
thanks,
-shane


0
e106199
6/22/2005 2:56:46 PM
Hi,

I am also trying to access a button Control back color from the form and getting the same error. Can anybocy help US??????Sad [:(]Confused [8-)]
0
r_haryu
6/23/2005 2:10:35 PM
Reply:

Similar Artilces:

I have a web user control being used by another web user control, but the one being used will not display the labels in the resx file.
I am using DotNetNuke version 3.13 (might be 3.013) on a Window's XP machine, SP2. I have what I find to be an extremely odd situation. I have a project called TDS.Controls. This project is a web control library. Each control has its own resx file, which is located in the App_LocalResources directory. Each control inherits from Framework.UserControlBase, just like DotNetNuke's User control in DNN\Controls\User.ascx.vb. As a matter of fact, this control is doing the exact same thing I am trying to do. It is a web user control with its own resx file being used by another web user control (See ...

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...

user control data entry form, use same codebehind as web form?
Hi All, I have a quesiton about the approach I'm taking. I have a series of report forms which I have been in the process of consolidating to a single, generic page and subs/functions in a single code-behind. All the reports can use the same set of data entry elements (a dropdown, a radio list, and a textbox). I'm trying to convert these elements to a user control. However, this user control seems to need to inherit differently than the rest of the code-behind. I've been using a single class in the code behind. Is it feasible to separate out the data entry? the code behind im...

How can a user-control know the name of the web form that uses it?
How can a user-control know the name of the web form that uses it? How can I code in the user-control access to controls of one of the web form that may use it? You reference the Parent property of the web user control in the user control code. For example, if you want to get a Button found on the web form that contains the current user control, you would put the following code in the code-behind of the user control (in C#): Button myButton = (Button)this.Parent.FindControl("myOtherControlButton"); The FindControl() method accepts the ID of the control you're ...

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...

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...

Can a user control communicate with another user control
I have several .ascx user controls on a page. Can they communicate with each other, or can they communicate with the page they are on? I guess I got in over my head by developing the page with user controls. Should I just remove the user controls and design the page without any? How do other people do it? Seems to me user controls are totally useless if you cannot place a value in one from another, or from the main page. You can create public properties in user controls, as with any other construct.  Give the UC an ID in the page, and the page can manipulate those public properties.As...

Can a user control contain another user control?
...? Sincerely,remedyMCP + Senior .NET DeveloperVista: Worth every penny. Yes, of course.Bertrand----This posting is provided "AS IS" with no warranties, and confers no rights. yes! this's ok!no problem!...

how to use an user control inside another user control?
as title, I can't wirte an user control inside an user control. how's the solution? thanks... you can. Then you gotta use the FindControl() method to manipulate it."Never argue with an idiot; He will drag you down to his level and beat you with experience"...

Using user control within another user control
Hi, Can I register and instantiate a user control within another user control. Yes, of course you can.  If you are doing it dynamically, then you have to remember that you have to do it in every postback there after. <%@ Register Src="usercontrol1.ascx" TagName="TagName" TagPrefix="uc1" %> <uc1:TagName ID="UserControlID1" runat="server" /> ...

Web user control inside update panel replace with another web user control
 Hi there. I have a page with a menu. an and then the content. My thing is. That i have the update panel, and inside that i have a regual panel in which i add the Web User Controls i need. Which all works fine. My problem is. That i i have a submit funcion on almoast all the Web User controls. What i would like is that i inside that update panel, can dispose the original Web user Control and then add a response Web User Control. In normal language. Is there a way that i can load one web user control into antoher and then disposose the original? Thanks in advance hello. well, what ...

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...

Solution for web forms that look just like paper forms ? User controls ? Adobe fillable forms ?
 I am looking at ways to web-enable a series of company forms that need to have the form itself look just like the paper version.  It would be great if I could use an image of the form itself as a background, and then draw the UI components on top of this.  Then there is the question of printing these forms complete with the data that was filled in.   What are some options for doing this kind of application ?  Im open to 3rd party solutions as well.  Our company currently has a desktop application which does this, but I want to come up with a web based solu...

How to access a user control from another user control in a Wizard control
My page has a wizard control and each step is a user control.  I could find the value of a control in step1 user control in the wizard page but not in step2 user control.From wizard.aspx.vb – it worksDim m_title As DropDownList = CType(Me.PersonalBox1.FindControl("ddlTitle1"), DropDownList) Question:How can I find the value of a control(textbox or dropdownlist)in step1 user control from step2 user control? I want to find “PersonalBox1.FindControl("ddlTitle1")” from Step2 AddressBox1. I have tried several ways to access it but no luck. From AddressBox.ascx.vb –...

Web resources about - (How) Can i use the form elements of a user control from another user control??? - asp.net.web-forms

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 ...

Grassfire near Leneva in Victoria's north-east now under control, fire authorities say
A grassfire burning near Leneva in Victoria's north-east is now under control, fire authorities say.

Publicis Said to Weigh Bid for Control of Cheil Worldwide
Publicis Groupe is weighing a bid for a controlling stake in Cheil Worldwide, people with knowledge of the matter said. The French company is ...

Oregon Pharmacists May Prescribe Birth Control - Al Jazeera America
Oregon is the only state to allow pharmacists to prescribe hormonal patches and the pill; California will soon follow

Playing around with BMW’s 7 Series gesture control user interface
We take a BMW 7 Series for a short drive to play with its gesture control. Video shot/edited by Jennifer Hahn. (video link) LAS VEGAS—Yesterday, ...

BMW recalls i8 for stability control problem
... , BMW , Safety , Coupe , Hybrid , Performance BMW will recall a small number of 2015 i8s because of a problem with the dynamic stability control ...

Embracing the NRA on gun control
I’m just stealing a massive post from Stonekettle Station on a plausible path forward towards sanity on guns: Those laws should be designed ...

This IBM programmer can control a BB-8 droid from 'Star Wars' with his mind
... decided to take Sphero's excellent "Star Wars: The Force Awakens" BB-8 app-powered droid and take it a step further with the ability to control ...

Want to Stay Comfortable? Ask Government to Mandate Temperature Controls on Thermometers
... ” should be considered for summer months, e.g. a maximum allowable temperature reading of 85 degrees Fahrenheit on all thermostats to control ...

Will gun control sink gun stocks?
Could new gun control measures hurt gun stocks? Boris Schlossberg of BK Asset Management and Gina Sanchez of Chantico Global discuss with Brian ...

Resources last updated: 1/14/2016 7:20:13 AM