HTML Text Box
-
hi all, Thanks in advance to you all.i have a html textbox in my asp.net form and i have email id's on that for validation.after finishing the validations i have to send the mails to the id's given in the text box.i want to know way to get the value of textbox to the c# code behind as the mail to send address of my application.please help me. like mail.To="value of the HTML textbox should come here" with regards, susa -- modified at 7:11 Monday 1st May, 2006
-
hi all, Thanks in advance to you all.i have a html textbox in my asp.net form and i have email id's on that for validation.after finishing the validations i have to send the mails to the id's given in the text box.i want to know way to get the value of textbox to the c# code behind as the mail to send address of my application.please help me. like mail.To="value of the HTML textbox should come here" with regards, susa -- modified at 7:11 Monday 1st May, 2006
All server controls have properties. You access a property's value using the syntax: ServerControl.Property The
TextBox
control has aText
property for retrieving or setting the text in the box. If your TextBox is named "MyTextBox", you would retrieve its value in C# this way:string myText = MyTextBox.Text;
You might benifit from a look at the QuickStart tutorials on http://www.asp.net[^].
-
hi all, Thanks in advance to you all.i have a html textbox in my asp.net form and i have email id's on that for validation.after finishing the validations i have to send the mails to the id's given in the text box.i want to know way to get the value of textbox to the c# code behind as the mail to send address of my application.please help me. like mail.To="value of the HTML textbox should come here" with regards, susa -- modified at 7:11 Monday 1st May, 2006
To get the value of a HtmlTextBox control from C# code behind, you have to convert the Control to a server control, not a web server control. just click on the control and select "Run as server control". set the ID propety in the preorties window. or you can add 'id="UName" runat="server"' this snippet in the textbox tag in the HTML view. example initially your control looks like the below,
<input type="TextBox">
alter it to<input type="TextBox" id="UName" runat="server">
know at the code behinde you can use the below code to get the valueSystem.Web.UI.HtmlInputText txtName = new System.Web.UI.HtmlInputText(); txtName = (System.Web.UI.HtmlInputText)this.FindConrol("UName");//Provide the ID you have given to the cotrol
nowtxtName.Value
will give you the textbox value hope this helps you Cheer. Ramesh.Kanjinghat -
To get the value of a HtmlTextBox control from C# code behind, you have to convert the Control to a server control, not a web server control. just click on the control and select "Run as server control". set the ID propety in the preorties window. or you can add 'id="UName" runat="server"' this snippet in the textbox tag in the HTML view. example initially your control looks like the below,
<input type="TextBox">
alter it to<input type="TextBox" id="UName" runat="server">
know at the code behinde you can use the below code to get the valueSystem.Web.UI.HtmlInputText txtName = new System.Web.UI.HtmlInputText(); txtName = (System.Web.UI.HtmlInputText)this.FindConrol("UName");//Provide the ID you have given to the cotrol
nowtxtName.Value
will give you the textbox value hope this helps you Cheer. Ramesh.Kanjinghathi, thank you ramesh for ur help by sparin ur time ,now i will try it out.i know it will work. sudharson.g with regards, susa