Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7403451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:05:08+00:00 2026-05-29T05:05:08+00:00

I have a HTML input box in my ASPX page like below <input id=txtID

  • 0

I have a HTML input box in my ASPX page like below

<input id="txtID" runat="Server" type="text" />

Now I have some code written in C# codebehind which calculate a value and I want that value to be displayed in the above TextBox.

I have already tried

txtID.Value = Number.ToString();

and

HtmlGenericControl ct = new HtmlGenericControl();
ct.InnerHTML = Number.ToString();
txtID.Controls.Add(ct);

but both of the above does not seems to set the display text of the textbox.

Can anyone help me figure out as to how do I get it done.
I cannot use

<asp:TextBox />

EDIT (WITH CORRECT ANSWER):
The way I was originally trying to do was correct i.e.

txtID.Value = Number.ToString();

The culprit was Placeholder Plugin which was getting called and was erasing the values from the TextBox. Hope this will help a lot of people like me who get stuck at such silly places.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:05:15+00:00Added an answer on May 29, 2026 at 5:05 am

    You can change value of control by injecting Javascript on PageLoad or PageInit. Just say GetValueDummy() method is your method to calculate a value and you are using jQuery.

    You need to inject a javascript to page in Page.Load handler.

    protected void Page_Load(object sender, EventArgs e)
    {
        var script = "$('#txt').val('" + GetValueDummy() + "');";
        ClientScript.RegisterStartupScript(typeof(string), "textvaluesetter", script, true);
    }
    

    In this code, txt is id of your input.

    If you are not using jQuery just replace value of script variable to

    var script = "document.getElementById('txt').value = '" + GetValueDummy() + "';";
    

    After some point your page will be fully rendered and ready to send to client. So you cant directly modify it from c#. You can read more about page life time here: http://msdn.microsoft.com/en-us/library/ms178472.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an HTML input box <input type=text id=foo value=bar> I've attached a handler
I have a html element (like select box input field) in a table. Now
I have below html code in my aspx. <input type=hidden id=medicalLink value='<a href=/forms/contactus.aspx >Contact
I have an input box like the following: <input type=text value= somethingSpecial=filename.txt id=myID class=box>
If I have an HTML input field like this one: <input type=text id=mytextfield/> all
I have html: <div class=box> <input name=radio-1 value=1 type=radio class=radio> <div class=hidden_box> some content
I have a form in a .html files where input/select box looks like this
I have a simple form with some plain html input like bellow using ASP.NET
I have the following problem: I have an HTML textbox ( <input type=text> )
I have input box txtRefreshInterval which allow only integer. <td><span class=sfFormlabel>Refresh Interval</span></td> <td><input type=text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.