Solved

Changing the value of an HTML element through C# code

Posted on 2011-09-23
2
163 Views
Last Modified: 2012-06-21
I can do the following to change the value of  an HTML textbox from C#:

<input type="text" name="email" id="myTextBox" runat="server" />
myTextBox.Text = "abc";

But, if the HTML controls are created through javascript, and if I have set runat="server", how can I achieve the above?

Basically, I am creating a seeries of textboxes using a for loop in javascript. Now, I want set their values using HTML.

Thanks!
0
Comment
Question by:dshrenik
2 Comments
 
LVL 17

Accepted Solution

by:
sonawanekiran earned 500 total points
ID: 36591372
You can not do this. You need to set the values only through javascript
0
 
LVL 12

Expert Comment

by:Ramkisan Jagtap
ID: 36591960
In java script you can access your controls using ID of you control.
incase your control myTextbox you can set value as below.

var mytxt=document.getelementById("myTextbox ");
mytxt.value="abc";


Regards,
Ram
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question