User Control
-
Hi, I have created user control called UserCtrl.ascs in my solution which includes two textboxes in that usercontrol and and also i have added the following code in .ascx.cs page. public string pUser { get { return TextBox1.Text.Trim; } set { TextBox1.Text = value; } } public string pPass { get { return TextBox2.Text.Trim; } set { TextBox2.Text = value; } I added that user control to my aspx page. Please tell me how to use that textboxes inside aspx.cs page. Thanks in Advance, Regards,
Prya
-
Hi, I have created user control called UserCtrl.ascs in my solution which includes two textboxes in that usercontrol and and also i have added the following code in .ascx.cs page. public string pUser { get { return TextBox1.Text.Trim; } set { TextBox1.Text = value; } } public string pPass { get { return TextBox2.Text.Trim; } set { TextBox2.Text = value; } I added that user control to my aspx page. Please tell me how to use that textboxes inside aspx.cs page. Thanks in Advance, Regards,
Prya
-
Hi, I have created user control called UserCtrl.ascs in my solution which includes two textboxes in that usercontrol and and also i have added the following code in .ascx.cs page. public string pUser { get { return TextBox1.Text.Trim; } set { TextBox1.Text = value; } } public string pPass { get { return TextBox2.Text.Trim; } set { TextBox2.Text = value; } I added that user control to my aspx page. Please tell me how to use that textboxes inside aspx.cs page. Thanks in Advance, Regards,
Prya
this.UserCtrl.TextBox1.value this way :)
-
Hi, I have created user control called UserCtrl.ascs in my solution which includes two textboxes in that usercontrol and and also i have added the following code in .ascx.cs page. public string pUser { get { return TextBox1.Text.Trim; } set { TextBox1.Text = value; } } public string pPass { get { return TextBox2.Text.Trim; } set { TextBox2.Text = value; } I added that user control to my aspx page. Please tell me how to use that textboxes inside aspx.cs page. Thanks in Advance, Regards,
Prya
As blue_arc said, you use user control from page codebehind same way as if it was standard ASP.NET web control. Assuming you have in your aspx file:
<uc:userCtrl runat="server" id="myCtrl"/>
in codebehind do:
string password = myCtrl.pPass;
Is it clear? :) You should not try to access textboxes directly, as it goes against encapsulation principle (hence I downvoted guy above me :P).
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus