C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » HTML »

Help Me Regarding HTML Controls


Posted Date: 12 Jul 2006      Posted By: umashankar beeraka      Member Level: Gold     Points: 2   Responses: 5



hi frnds,
I am having a small doubt regarding the HTML controls. I want to access the HTML controls' value in the code behind file. How will I achieve this.
I will explain the Scenario;
i am creating a web form for user login. for that i took two html text fields. and one asp.net server button control. Now when i enter some values in the two html textboxes and press the button,now i want to retrieve the values of the two html textboxes from the code behind file. how can i achieve this.please guide me to achieve this.

Thanx in Advance
UmaShankar Beeraka





Responses

Author: Vikas Joshi    12 Jul 2006Member Level: BronzeRating: 2 out of 52 out of 5     Points: 2

Dear Mr. UmaShankar,

To make use of any HTML control into code behind you have to make the following two changes into the Control...

1. Add the runat=server attribute to the control and place the control inside the form tag
2. Add a ID to that control

Now by these two steps you can access the controls the same way you are using the builtin Web Server controls.

Thanks

Vikas Joshi



Author: dotnet    13 Jul 2006Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

hey use
request.form('id of control')
to get the value of textbox



Author: dotnet    13 Jul 2006Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

first of all set runat="server" to control put some id after that
use
request.form("id_of_control").tostring()



Author: Vikas Joshi    13 Jul 2006Member Level: BronzeRating: 2 out of 52 out of 5     Points: 2

Hi,
If you require that the control should be a HTML Control then for that you have to do some workaround for that ..

Please follow the following steps :

Add the onClick attribute to the Button Server control.. And then on Click of this Button at Client side Assign these HTML Controls Value into any other filed lets say a Hidden Variable in a Commo or : Seperated way and get this value in the code behind of the page ..through this you can acheive what you want .. means no need to change the Page only add the Client side Click and do the desired on n number of items on the Page...

Hope this solves your problem

Thanks

Vikas Joshi



Author: ankur jain    20 Oct 2008Member Level: SilverRating: 2 out of 52 out of 5     Points: 3

Hi UmaShankar,
Firstly put runnat="server" to yor html text fields say txtLogin and textPassword.
On asp button Click event in .cs file acess these values as
string a = txtLogin.Value;
string b= textPassword.Value;



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : What are HTML controls and Server controls
Previous : How to call Html input controls in code behind file?
Return to Discussion Forum
Post New Message
Category: HTML

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use