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

  • Home
  • SEARCH
  • 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 8501853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:19:22+00:00 2026-06-11T01:19:22+00:00

In asp.net website, inside .aspx i have following code <script type=text/javascript> function callme(option) {

  • 0

In asp.net website, inside .aspx i have following code

<script type="text/javascript">
    function callme(option) {
        document.getElementById("t1").value = option;
    }
</script>
<div id="content" runat="server"></div>

<input type="text" id="t1" />

On code behind file inside Page_Load:

content.InnerHtml = MyClassObject.MyMethod(...);

Inside MyClass:

public String MyMethod(...)
{
   ... //some code
   String str1 ="<select id=\"s1\" onchange=\"callme(this.value)\">" +
                    "  <option value=\"1\">One</option>"+
                    "  <option value=\"2\">Two</option>" +
                    "  <option value=\"3\">Three</option>" +                          
                    "</select>";
   ... // some code
   return str1;

Whenever i select any option from dropdownlist it reflects its value inside the textbox t1.
But at page load the textbox remains empty. I cannot use default value as the values of the dropdownlist are changing at runtime.
How can I add first value of dropdownlist to textbox t1 on page load?

  • 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-06-11T01:19:24+00:00Added an answer on June 11, 2026 at 1:19 am

    In your onload function in javascript you get the currently selected value in a drowdownlist as follows:

    var s1 = document.getElementById("s1");
    var selectedVal = s1.options[s1.selectedIndex].value;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have folder in my asp.net website ..namely admin i have following pages inside
I have a asp.net website folder namely Website3 inside website3 folder there is a
I have a silverlight application which I load inside a an asp.net website via
OK, here is the question, I have a asp.net website, there is an aspx
I have an asp.net website that stores events inside a database table. Then I
I have an ASP .NET Website where i have an index.aspx page and 3
I have an ASP.NET Web Forms web site. It has a page inside of
ASP.NET newbie here I have coded up an ASP.NET website and running on win'08
We have a ASP.NET website project. In the past, we had been using asmx
I have a asp.net website with a logo. When I go on facebook or

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.