C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




reading the textbox values which is in usercontrols in Windows applications in c#


Posted Date: 26 Jul 2008      Total Responses: 2

Posted By: A.raghavender       Member Level: Gold     Points: 1



reading the textbox values which is in usercontrols in Windows applications in c#




Responses

Author: Vidhya    26 Jul 2008Member Level: GoldRating:     Points: 1

How to call user controls value (like Textbox, button, checkbox etc.) in aspx page.

When you use usercontrols in your form it’s very easy to get that user control value in your form.

I am taking one example you are creating one Usercontrol that have two textbox with User Id and Password.
And this usercontrols you can use in your form either Load that control run time or Drag that control in your form design time.

1) Create one usercontrol name: Test.ascx
That have one panel on design time name: Panel1
Call this method (AddControls) in Page_Load() event in your
UserContorl Page (Test.ascx)


public void AddControls()
{
Label lblUserName;
Label lblPassword;
TextBox txtUserName;
TextBox txtPassword;

lblUserName = new Label();
lblUserName.Text ="User Name : ";
txtUserName = new TextBox();
txtUserName.ID="txtUserId1";
lblPassword = new Label();
lblPassword.Text="Password : ";
txtPassword = new TextBox();
txtPassword.ID="txtPassword1";
txtPassword.TextMode =
System.Web.UI.WebControls.
TextBoxMode.Password;

Panel1.Controls.Add(lblUserName);
Panel1.Controls.Add(txtUserName);
Panel1.Controls.Add(lblPassword);
Panel1.Controls.Add(txtPassword);
}


2) Create one form name: TestUserControls.aspx now
There are two ways to use this usercontrol in your form(TestUserControls.aspx)

a) Drag this usercontrol in your form




OR

b) Load this user control in Page_Load() event in your form
(TestUserControls.aspx) where you are using this control.




Author: Sabu C Alex    28 Jul 2008Member Level: GoldRating:     Points: 3

hi

create properties for setting and getting values to Textboxes in usercontrol. So that you can assign values to textbox using this properties from codebehind.



Post Reply
You must Sign In to post a response.
Next : what is E-R diagrams
Previous : Skin Files in Visual Studio
Return to Discussion Forum
Post New Message
Category: Windows

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use