• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 183
  • Last Modified:

Changing the value of an HTML element through C# code

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.

1 Solution
Kiran SonawaneProject LeadCommented:
You can not do this. You need to set the values only through javascript
Ramkisan JagtapLead DeveloperCommented:
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 ");


Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now