Article View: borland.public.csharpbuilder.language.csharp
Article #270Re: How to get value from a HTML Textbox control in code-behind?
From: Joe Mayo
Date: Thu, 15 Dec 2005 03:05
Date: Thu, 15 Dec 2005 03:05
41 lines
1911 bytes
1911 bytes
Hi Peter,
The HTML TextBox runs only on the client by default. To access it on the
server, add a runat="server" attribute to it, declare it in your code-behind
with a variable name that matches the control id, and access it's Value
property.
For example, declare the HTML like this:
<INPUT id="Text1" type="text" name="Text1" runat="server">
Declare it like this:
public class WebForm1 : System.Web.UI.Page
{
...
protected System.Web.UI.HtmlControls.HtmlInputText Text1;
...
}
And get its value like this:
string htmlText = Text1.Value;
Joe
--
http://www.csharp-station.com
"Peter Jones" <peter@hotmail.com> wrote in message
news:4395d78f$1@newsgroups.borland.com...
>
> Hi,
>
> Could someone please tell me how to get value from a HTML
> Textbox control in code-behind?
>
> To get the value from web control, I know I can
> write "Textbox1.Text". But I have no clue for the HTML element.
>
> Thanks in advance,
> Peter
Technical Details
Message-ID:
<43a0dd0b@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.volia.net!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4395d78f$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,df9c4834d8a6dfc2 X-Google-Attributes: gid1efe35,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Joe Mayo" <jmayo@nospamAtCSharpDashStation.com> Newsgroups: borland.public.csharpbuilder.language.csharp References: <4395d78f$1@newsgroups.borland.com> Subject: Re: How to get value from a HTML Textbox control in code-behind? Date: Wed, 14 Dec 2005 20:05:07 -0700 Lines: 43 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2670 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 NNTP-Posting-Host: 64.135.165.190 Message-ID: <43a0dd0b@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1134615819 64.135.165.190 (14 Dec 2005 19:03:39 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.volia.net!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail