How to pass textbox control value from UserControl page(ascx) to Page Control(aspx).

I have 2 files(aspx and ascx). the aspx page  has a Web user control(ascx) in it.
Once the button control click(in aspx) I want to get the value from the textbox(ascx) control
and pass it to label control in aspx page.

Can somebody help with this and please use VB.


11/29/2005 6:32:48 PM 93655 articles. 6 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 2

A simple search would have turn up many different solutions.  The easiest is to just expose the textbox value as a property in your control.  Then you can retrieve that value on the aspx page.
11/29/2005 8:03:15 PM

Add this to your control:

Public Property TextBoxValue() As String
         Return TextBox1.Text
   End Get
   Set(ByVal Value As String)
        TextBox1.Text = Value
   End Set
End Property

Add to your parent CodeBehind:
       Protected WithEvents yourControl As control-name-space.control-class-name

Then to get the value
       Dim textBoxValue As String = yourControl.TextBoxValue


11/29/2005 8:31:50 PM
Add a Property to your Control to return the value from your TextBox, 


Public ReadOnly Property GetTextBox1Text()
      Return Me.TextBox1.Text
   End Get
End Property

Then in your ASPX codebehind, create a reference to the control and call the Property on your User Control

Protected WithEvents Mycontrol As TestControl

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
   'Get a reference to our Control
   Mycontrol = CType(Me.FindControl("TestControl1"), TestControl)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
   Me.Label1.Text = MyControl.GetTextBox1Text
End Sub

Or you could use the below, and not have the variable declaration and assignment in the Page_Load.  If you have multiple properties in your control, the above makes it very easy for you to get any of the properties values. 

Me.Label1.Text = CType(Me.FindControl("TestControl1"), TestControl).GetTextBox1Text
Script your Stored Procedures and class objects necessary for your .net application. Accelerating your development time, creating a consistant easily maintained class object Library.
11/29/2005 8:35:39 PM

Similar Artilces:

Pass value(textbox) from .aspx page to .ascx page
Hi All, I have created one Menu as a user control,in which I have one label control.At my web page(Products.aspx),I am receiving a value from a textbox,which I want to pass on to a user-control's label value.So that when ever value is increasing in textbox,label value will also get incremented accordingly.   Regards, Montu You'll probably need to use the TextChanged event of your TextBox in which you'll then send the current contents of your TextBox to a property within your UserControl which directly loads the Text property of your Label control.Thanks, EdMic...

Passing large amount of data (dataset) to a userControl (Windows forms userControl derived control) in an aspx page
I've been searching for a while an answer without any good results and/or clear vision of a real nice solution.I'm looking for the best solution to pass large amout of data to a userControl (Windows forms control) in an apsx page. Actually, we pass the web address of a web service to the userControl and this userControl retrieve the info itself. We have few problems with security (web address seems to have to be the same naming as the one used for the page). Also, it seems better to me to retrieve the datasource in the page and give it to the control (or give the control kind of a p...

pass value from modal popup in ascx page to textbox in aspx page
Hi everybody, i've a user control (ascx file) contains one button, when i click this button a modal popup should appear. This popup contains a gridview so i could select one record so the id of this record will store in a hidden control after that i click the ok button. i used this user control on a aspx page which have an empty textbox. What i want is when i select a record and click ok on the popup the textbox on the aspx page take the value of the hidden control in the ascx page. i tried to make that but the ok button on the popup didn't make a postback so the value of the text...

Accessing server control values of a web user control from ASPX page
Hi, I have created a web user control (ascx) page with several server controls and the web user control included in a aspx page. I have a command button in main aspx page. How can I access values of the controls in web user control from onclick event of the aspx page. Thanks, Chamil. Make the controls on the web user control public.Darrell Norton, MVPDarrell Norton's BlogPlease mark this post as answered if it helped you! Could you pl. give me a sample line of code on how to make the control public. thanks, chamil Are you developing inline or with a code-behind?...

How to set textbox control value in ascx from aspx page
 Hello Everyone,I think this probnlem is already posted on the forum. But i can't find any solution about it so i am posting it. I am finding probelm to set TextBox control value in .ascx control. My scnario is that: I am dynamically adding ascx control in aspx page means that i've 3 users in list and i want to show every users credentials. I am doing like that i added textbox control in ascx control writing get set properties for each web control.In aspx page i am setting these values by traversing list. It is working fine. But i am finding problem that when i try to change val...

How to pass values from .ascx control to aspx.cs page
I have created two controls to collect different information. The controls were created so the visibility can be controlled by the user depending on their choice. I think the problem lies in passing the information from my .ascx control to the aspx.cs page. I know if I can pass the information to a <asp:label... and display it on the page then I can use the same method to pass the information to a stored procedure parameter. With that being said, this is what I have. After the information is entered into the control and the save button is clicked (the save button is part of ...

How to pass values from window form control to Web page !!!
Hi i have a window form control which is downloaded on the client's machine.and it writes a binary image file on the client's machineAnd now i have to get this binary image file from client's machine and save it to database.Plz tell me Is this possible using window form control???OR there is any another way so that i can access the binary image file from client's machine.Thanks in advance.  Good luck on that one! This sample might help. It passes a string value from a windows component to the web page. //////////////////////////////////////////////////////////////////...

Pass values from one user control to a user control on a different aspx page
Hello, I have an aspx page titled Search.aspx. Within this page, I have a user control titled Search.ascx. I want a user to input search terms, then on the click of a button, I want to pass the values to another page (SearchResults.aspx)....which will then display the results in a user control. Can someone please give me some suggestions on how to do this? Thanks a lot! Hello, what you can do is: inside ur usercontrol, create a method that returns a dataset or datareader. that is, since u are searching using the usercontrol, then the result of ur search will be return...

how can i access .ascx (user control) controls like textbox,label .... from .aspx page
 I have 2 textboxes in my web user control(.ascx).i need to set some value to those textboxes from my .aspx page how is it possible.any one plz help me..............................  waiting for your solution :-)  :-)   Thankyou in advance ,have a greate day>>>>>>>>>>>>>>>>  You can try something like this from your aspx page's code behind: Dim txtTest As Textbox txtTest = usercontrol.FindControl("textbox_name_on_control") txtTest.Text = "the text you need"  &nb...

Control of the page and the controls on a page
I am building a web app that has some pages that are public and some that are only available based on subscription. Could someone explain the best way (infrastructure wise) how to control whether a server control is visible or enabledand how to control whether a page is viewable or not based on the user and whether or not the user is logged in (or not). If a user is not logged in I would like some controls to be visible but disabled. I also have to control the URL's in case a person learnsthe URL and tries to type it in. My question is more towards how to do this database wise. I am u...

Controlling ascx page in aspx page
Hi all, Im totally new in and i have a few questions. I have several page's and on each page i use a header.ascx to display the header on each aspx page. How can i control for example a label (lblCustom.text, lblCustom.visible) wich is placed in my ascx file with code in my aspx page ?? My second question?? I want to email some information to several people in my web application. The problem is the content of the email is not displayed very nice, for example username:.......test password: ...................abcdfdf Address: .....teststreet (the dots are ...

How to pass form values to a page using button web controls?
I am having problems working out how to produce some code for a web site administration section. What I am trying to do is to show a list of the categories, as taken from the database. There are then buttons to edit or delete a selected category, as well as the ability to add a new category. What I have done previously, in ASP, is to have a form at the top of the page with a couple of hidden fields, one for the action and one for the category ID, and then used javascript to change those values according to which button was pressed, and submitted the form. So far, I have used a Repeater...

how to pass ddl1.selectedvalue from a content page to a User Control page ( ascx page)
 Hi All,I have a DropDownList in a content page. i would like to access its selectedvalue my user control page. the below is DDL<asp:dropdownlist id="ddl1" runat="server" autopostback="true">            <asp:listitem value="6" >6</asp:listitem>            <asp:listitem value="12" >12</asp:listitem>            <asp:listitem value="24"...

controlling an object in a web control from the page the web control is placed in
I have created a web control in that has an image button and an image. when it loads the image button is visible and the image is not. I want to be able from the page which "includes" the web control to set the image button to invisible and the image to visible. When I tried this, the main page didn't recognise the image button or the image (both < asp: objects). help would be gratefully appreciated. oh yeah, it's inline code so any code behind stuff will just confuse me ;) Some code please.-- Justin Lovell...

How To Pass an ItemId from one ascx control to another ascx control in the same page
Hi All, I am new to Asp 2.0. previously i worked on DotNetNuke. now i shifted to this asp 2.0. and here i am developing a site in that site i am using controls just like modules in the dotnetnuke. so i got one doubt here that is in the dotnetnuke if i want to pass an id from one ascx control to another ascx control there i used EditUrl function so it is very simple. but here there is not such a function for navigation from one ascx control to another ascx control. so can any body help me regarding this.Regards,Ram Mohan Rao Adduri,Techinical Associate,eSymbiosisHyderabad.Mobile: 9490118545...

Pass value from Child page to Parent page ( to locate sub controls of parent page )
Team, This is a question related parent and child webform or webpage. My utlimate aim is to pass or update a control of my parent page from child page. The Design   Parent Page --------------   Parent DataList 1       Child DataList 1          Textbox1 Textbox2 Textbox3 Textbox4       Child Datalist 2          Textbox1 Textbox2 Textbox3 Textbox4       Child Datalist 3     ...

i have 3 pages student information , i filled two pages ,then go to 3rd page . First Two pages iam having 100 to store that controls and how to send these controls into 3rd page in ?
i have 3 pages student information , i filled two pages ,then go to 3rd page . First Two pages iam having 100 to store that controls and how to send these controls into 3rd page in ?  There are a number of ways storing values. Check out: Thanks,Karan~ Remember To Mark The Post(s) That Helped You As The ANSWER ~ Hi, Welcome to forums. Now as far as your requirements goes, the first thing that strikes me is that 100 controls are way too many to kee...

Validating web user control(ascx) in parent page (aspx) -- .NET 1.1
Hi,  I have a user control which has some server controls like drop down list, list box etc. These fields are required. I'm using this control in a parent page which has its own server controls which are also required. The button on the parent page which is supposed to validate the controls is not working after I add the web user control.  Is there a work-around for this scenario  other than manually calling Page.Validate() and checking for Page.IsValid property ? I tried calling a javascript on button click which calls Page_ClientValidate() whic...

Passing a value from one aspx page to all remaining aspx pages in a web app
hi, i want to pass a value (label text) from one page to all remaining pages in my web app. i know how to pass from one page to another. how to pass single value to all remanining pages   thanks in advance use session object like if u have to pass the label text from default.aspx to default2.aspx then write this code in default.aspx session("name of the session object")=label1.text and in default2.aspx page load event write dim a as string=session("name of the session object")=   hope it will do byee from:gunjan jhagunjan12hjp@gmail.comgunjan ...

Control Menu in ascx page from aspx page
Hi all, Hope you can help. I have a menu in an ascx page that I want to change the visible status on based on whether a user is authenticated or not. If on the aspx page I try to change the state of the menu, I get the error that the menu is protected. I have very limited programming experience and can't find any info on this All help is welcome   Argy     In the Page_Load() Event, do this: If Page.User.Identity.IsAuthenticated = True Then Menu1.Visible = False Else Menu1.Visible = True End If  Specializing in ASP.NET 2.0 Thanks,   That solved my problem...

Single page with multiple user web controls VS Multiple page with specific user web controls
I have a question regarding single page with multiple user web controls vs multiple page with specific user web controls   Option 1: I am of the opinion to have multiple pages with specific user web controls and use an object to store all the information as the user navigates through the application. And finally at the end, read this object and save all the information to the backend database.   Option 2: My respected team member suggests that we have only one page, with all the specific user web controls and not use an object, instead show/hide the user web controls based ...

Web page .aspx is slow when loading. Pages have web user controls on them that are loaded dynamically
I have written a web application using VS 2003. Several of my forms have web user controls on them. The controls are loaded dynamically at runtime. The problem is that the web pages are very slow to load. Does anyone know if there is a way to speed up the pages being loaded into the browser? Here is an example of some code I use to dynamically load the controls:  private void Page_Load(object sender, System.EventArgs e)  {   // Put user code to initialize the page here   // Put user code to initialize the page here    Control marketWebUserControl = Page.LoadControl("Market.ascx");   // Typecast the user control to the strong name   // And set its properties    //((Market)c).BackColor = Color.Beige;      MarketSubMarketPh.Controls.Add(marketWebUserControl);  }  Honestly it all depends what your controls are page is doing.... Some general hints is to remove viewstate if possible and second check the size of the page that's being created in html.... By viewing the source and saving that text file, you could be amazed at the size...  Another idea would be to trace your page and see what's killing the load time.. To do this simply add Trace=True in your <@ Page declarative. on the aspx page.   Oh one more thing.... Instead of dynamically adding your controls if it's not necessary i would suggest jus...

I used Passing Server Control Values Between Pages, and tried to call the receiving page as the start page, this causes an error!
 The error states thatUnable to cast object of type 'ASP.homepage_hp_aspx' to type 'ASP.FirstPageClass'.and is pointing to thefp = (FirstPageClass)Context.Handler; in <script runat="server">        FirstPageClass fp;        protected void Page_Load(object sender, EventArgs e)        {            if (!IsPostBack)            {  &nb...

How to fetch value from Html Page controls to aspx page
I have two html text boxes with id txt1 and txt2 and one html submit button ie. <input id="Submit" type="submit" value="Submit" name="submit" /> and in the top in the form tag i have written <form id="form1" name="form1" method="post" action="test.aspx" >   Now I want To ask u that how would i get the values of these text boxes in test.aspx form.   Plz Help Me.RAGHAV MVP ASP/ASP.Net Read My Blog MARK THE POST AS ANSWER IF IT HELPS U. "Success doesn't come to you…you go...

Web resources about - How to pass textbox control value from UserControl page(ascx) to Page Control(aspx). -

'url' Top Users - Stack Overflow
current community chat blog Stack Overflow Meta Stack Overflow Stack Overflow Careers your communities Sign up or log in to customize your list. ...

List of content management frameworks - Wikipedia, the free encyclopedia
.NET Framework , works with SQL Server, VistaDB , with XSLT or .NET UserControls Text is available under the Creative Commons Attribution-ShareAlike ...

OPAC Discovery
Switch Language To switch to a different language, select from the following list: English French Spanish Italian British Bulgarian Galician ...

The royal baby - Australian Women's Weekly
MAKE AWW MY HOMEPAGE SUBSCRIBE AND SAVE TODAY FOOD RECIPES ROYALS CELEBS Home Food Recipe search Recipe collections Meal maker Expert Q & A Cookbooks ...

Envoyer par courriel à un ami - Best Buy Canada
Envoyer par courriel à un ami à Best Buy Canada

Bytes - IT + Developer Community - Connect with IT Pros is a community for Developers and IT Professionals. Join 414,150 members and discuss topics such as software development, networking, ...

Canonical Splines in WPF and Silverlight
January 22, 2009 New York, N.Y. Windows Forms has two methods named DrawCurve and DrawClosedCurve that draw canonical (aka cardinal) splines. ...

Silverlight Toolkit - Issues
Silverlight Toolkit and Silverlight for Windows Phone Toolkit are a set of Microsoft components for developers.

Keep, share, and discover the best of the Web using Delicious, the world's leading social bookmarking service.

DotNetNuke Modules – Anatomy of the View
-*+Now that we’ve laid the foundation of DotNetNuke modules, it is time to start looking at the specific modules. While it would be practically ...

Resources last updated: 3/7/2016 12:04:33 PM