How to get Textbox value in web user control?

Hi friends,

I created a web user control with only one textbox.(textbox.ascx) and textbox id=" txtSimple"

textbox user control having some property. 

another user control with button(button.ascx)


next i use two textbox usercontrol and one button usercontrol in sample.aspx.

 when i click button at that time call the required field validate property in textbox user control.

in property have following code.

public bool RequireValidate
            bool isValid= value;
            if (isValid)
                if (!txtSimple.Text.Equals("") && txtSimple.Text != null)
                    lblRFV.Visible = false;
                    lblRFV.Visible = true;
                lblRFV.Visible = false;
    } .

but always come empty value.Why?

How to get correct value?



5/19/2008 9:47:46 AM 91979 articles. 3 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 1

FirstÖ instead of


if (!txtSimple.Text.Equals("") && txtSimple.Text != null)

should use




and second

simply use a property in usercontrol to access text property of textbox

public string SimpleText




        return this.txtSimple.Text;




      this.txtSimple.Text = value;



That is it. Its simple. 



Please remember to Mark As Answer if this post answered your question!
5/19/2008 10:27:12 AM


Based on my understanding, you want to access the control which is in the UserControl from another UserControl. If I have misunderstood you, please feel free to let me know.

You can use the below code to achieve it:


Hope it helps.


Vince Xu
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
5/21/2008 9:54:06 AM

Similar Artilces:

How can I get the textbox value from a web user control inside an iframe?
Hi there, I have a page p1.aspx which has an iframe, if1, and a button sb1. The source of if1 is p2.aspx which has a web user control uc.ascx. In uc.ascx, there is a textbox, tb1, for user to enter a string. My question is: Is it possible to get the text of tb1 of uc.ascx in the p1.aspx when I click the button sb1? And How? Thanks in advance....

How to get the HREF value of the Anchor tag in a web page using the web browser control in
Hi Friends,               i have a webserver control in my application.i load the web browser control on a button click using the below code Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click                AxWebBrowser1.Navigate("", False) End sub once the page is loaded in the browser i want the <a> HREF value in that page.For example if that page has ...

Getting value of a property in Parent User control from a Child user control
I have a ChildUserControl that is loaded inside a ParentUserControl. The host page loads ParentUserControl.I would need to access properties in ParentUserControl from the ChildUserControl.Thanks for your time Here's some ideas: You can from the child access the parent and run findcontrol. child.parent.findcontroL("indyanguy1") child.parent.parent.findcontrol("indyanguy1") The trick is when you get your findcontrol working to cast the result to the object type your looking forHere I'm looking for a label so I cast to label then I can use the .Text property.Y...

Get user input from dynamic created control, why i cant get the value???
Hi!, i was tried to dynamically generate some textboxes according the selected number in a dropdownlist, but when i need to get the user input from those textboxes.. i cant get at all!!, Can any1 guide me on tis? Below is my code.Basically, i have 1 dropdownlist (ddltbCount), 1 placeHolder(Pholder1), 1 button(btGetValue), i dont know y i cant post the html here... Private count As Integer = 1 Sub IterateThroughChildren(ByVal parent As Control) For Each c As Control In parent.Controls If c.GetType.ToString.Equals("System.Web.UI.WebControls.TextBox") AndAlso c.ID Is Nothing Then ' CType(c, T...

Custom web control. Get Textbox.text value
Hi I have created a custom web control that extends the CheckBoxList control. It basically is a CheckBoxList control that has a TextBox added to the end of each CheckBox. It looks like the following after it has being bound to a database table column. I need to be able to retrieve the values in the corresponding TextBox when a CheckBox is selected. I tried storing each TextBox in an ArrayList but it is always empty when I try and check it. I am pretty new to ASP and am obviously missing something. Has anybody here got any tips or ideas on how I could retrieve the data from the TextBoxes...

cant get web user control page value
i have a page web user control (ascx file), name =criteria in the ascx page i have a dropdownlist, name = Field1 the ascx page have a function Function GetValue() as string    Return Field1.SelectedItem.text Ebd Function now i include the ascx file to my web form with button ''''button at the web form not ascx file in button click events Dim Str as String Dim objCriteria as new Criteria  ' Criteria is ascx page class name Str = objCriteria.GetValue But at runtime i get an error say null reference exception how to solve the problem? i using VS 2005 and .ne...

Cannot get value from an input textbox to a listbox web control??
I am about to go nuts because I really have not done any Asp.Net programming up until now. I have mainly done desktop applications. I am trying to take the textbox in the page and pass the contents of it to the listbox on the same page. I cannot get the values from the textbox to the listbox. Below is my code for the aspx page and also for my code behind page. Can someone please tell and show me where I am going wrong? aspx page:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AspNetPolyDraw.Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML...

getting/setting a value in a web user control (ascx)
I have created a simple web user control that has a textbox and a calendar on it. When the user clicks on the calendar, the textbox is filled with the relevant date. What I want to do is be able to get that date from the parent webpage. I also want to be able to set a couple of variables saying whether a requiredFieldValidator is enables, and there is a default date. Hopefully, the answer to above would help in this aswell. Can anyone help?Intelligence is a burden.Jagdip Singh AjimalManchester (and yes, I am a Manchester United fan) You must declare a public property in your User ...

problem with get value from textbox after get it value in load page
hi every one  i have problem with my web site when i get textbox value in load page   and Changed textbox the page do not take last value .   it take value in load page   this is code:Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)   TextBox1.Text = "aa" End SubProtected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) MsgBox(TextBox1.Text) End Sub   when i press button message write "aa" while i changed the textbox   please if enyone knowen help me &nbs...

Client site code to get value from textbox within Custom User Control??
Hi, I have created a custom user control that contains a text box, that text is placed in by the user (I cannot access the value of the text via code-behind!). I load three of these custom control on to an aspx page: <uc3:imagedialogcaller id="ImageDialogCaller1" runat="server" /> <br/> <uc3:imagedialogcaller id="ImageDialogCaller2" runat="server" /> <br/><uc3:imagedialogcaller id="ImageDialogCaller3" runat="server" /><br/> I want to be able use some client site code to get the value of the ...

How get value from a dynamically created control in a user control
HI, I am working with a version of IBuySpy. On one page is a form that contains a user control that lists the items the user purchased, the subtotal, shipping, etc. I wanted to add a DropDownList from which the user could select the shipper. The dropdown list works fine as long as it has .AutoPostBack = false. However, I cannot figure out how to get the value that the user selected when they finally press the submit button on the form. All attempts to locate the control and it's value have failed. I tried drillingdown from the form to the child controls, and sub child controls. N...

Getting value from a textbox control that was filled with a value from javascript
 I have a textbox control (seen below txtMileageDollars1) that gets filled with javascript based on the number of miles a user types into another textbox (txtMileageMiles1) control.  When I post back with the submit button, the value is blank.  I've tried setting EnableViewState to false, but still cannot get a value on postback.  Does anyone have a solution?   Miles<asp:TextBox ID="txtMileageMiles1" runat="server" Width="50px"></asp:TextBox>   Total (txtMileageMiles1 * rate with javascript)<asp:TextBox...

How to get the value hidden control of user control in .aspx page
How to get the value hidden control of user control in .aspx page   Thanks srinivas  If its a server control (runat attribute = server) and its markup starts with <asp:HiddenField ID="HiddenField1">, you can just call HiddenField1.Value to get the value stored in it. Even if your hidden field is not a standard control you can still retrieve the value provided the runat attribute is set to server.Hope this helps programming blog Use <%=testhid.ClientId%>For example getting a reference to the object would look like:var testid = document...

How do I get get values of controls inside datalist?
How do I get values of controls inside datalist?   For example, if I have a label inside header template or item template or footer template? Is there anyway to change property of label or any other controls inside those template as well? I would really appreciate if anybody can just post a sample code or a helpful link about datalist? Would really like to know more about the events fired for datalist, itembound, itemcreating etc?   hey there,I used this page to work out how to use datalists

Web resources about - How to get Textbox value in web 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 ...

Firefighters battle out of control bushfire in Bullsbrook
Around 70 firefighters are battling an out of control bush-fire in Bullsbrook.

Firefighters battle out of control bushfire in Bullsbrook
Around 70 firefighters are battling an out of control bush-fire in Bullsbrook.

Firefighters battle out of control bushfire in Bullsbrook
Around 70 firefighters are battling an out of control bush-fire in Bullsbrook.

Firefighters battle out of control bushfire in Bullsbrook
Around 70 firefighters are battling an out of control bush-fire in Bullsbrook.

Victorian bushfires: Fire crews battle to get blazes under control in hot, windy conditions
Several fires continue to burn in hot, windy conditions in Victoria, but all of the emergency warnings have been downgraded, CFA officials say. ...

Stringify your life by taking control and automating tasks
... Adobe Post or If you can think it, you can create it in Scribblenauts Unlimited . Stringify IF by IFTTT Stringify your life by taking control ...

How to engage Tesla's Launch Control mode
Filed under: Green , Videos , Tesla , Electric Short video shows Model S keeping it straight on a rain-slicked road.

Tencent Holdings Takes Full Control of 'League of Legends' Developer Riot Games
Breitbart News Tencent Holdings Takes Full Control of 'League of Legends' Developer Riot Games Breitbart News Riot Games, the creators of ...

China's Xi on cyberspace control
Chinese President Xi Jinping defended his country's right to censor Internet content, signaling confidence in the strategy.

Resources last updated: 12/20/2015 4:21:10 PM