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 8018175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:04:19+00:00 2026-06-04T21:04:19+00:00

I have written one JavaScript function as follows: function CalcTotalAmt() { ———- ———– }

  • 0

I have written one JavaScript function as follows:

 function CalcTotalAmt() 
 {
    ----------
    -----------
 }

I have one DropDownList,

  <asp:DropDownList ID="ddl" runat="server"  AutoPostBack="true" OnSelectedIndexChanged="ddl_SelectedIndexChanged"></asp:DropDownList>

I need to call the above JavaScript function in the DropDownList’s SelectedIndexChanged Event.
I tried like below;

protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
{
    ddl.Attributes.Add("onchange", "return CalcTotalAmt();");
}

But the JavaScript function is not executing.
How to call the JavaScript function in DropDownList Change Event?

  • 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-04T21:04:20+00:00Added an answer on June 4, 2026 at 9:04 pm

    First Method: (Tested)

    Code in .aspx.cs:

     protected void Page_Load(object sender, EventArgs e)
        {
            ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged);
            if (!Page.IsPostBack)
            {
                ddl.Attributes.Add("onchange", "CalcTotalAmt();");
            }
        }
    
        protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
        {
           //Your Code
        }
    

    JavaScript function: return true from your JS function

       function CalcTotalAmt() 
     {
    //Your Code
     }
    

    .aspx code:

    <asp:DropDownList ID="ddl" runat="server"  AutoPostBack="true">
            <asp:ListItem Text="a" Value="a"></asp:ListItem>
             <asp:ListItem Text="b" Value="b"></asp:ListItem>
            </asp:DropDownList>
    

    Second Method: (Tested)

    Code in .aspx.cs:

    protected void Page_Load(object sender, EventArgs e)
            {
                if (Request.Params["__EVENTARGUMENT"] != null && Request.Params["__EVENTARGUMENT"].Equals("ddlchange"))
                    ddl_SelectedIndexChanged(sender, e);
                if (!Page.IsPostBack)
                {
                    ddl.Attributes.Add("onchange", "CalcTotalAmt();");
                }
            }
    
            protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
            {
                //Your Code
            }
    

    JavaScript function: return true from your JS function

    function CalcTotalAmt() {
             //Your Code
         __doPostBack("ctl00$MainContent$ddl","ddlchange");
     }
    

    .aspx code:

    <asp:DropDownList ID="ddl" runat="server"  AutoPostBack="true">
            <asp:ListItem Text="a" Value="a"></asp:ListItem>
             <asp:ListItem Text="b" Value="b"></asp:ListItem>
            </asp:DropDownList>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have written one javascript function to retrieve the position of a button and
I have written one JavaScript function which would rise the event when the User
In my client app—written in javascript and jQuery—I have a function where I'm doing
I have written a simple Javascript function (curteousy of codecall.net ) that creates a
I have written the below html code with the embedded javascript function disableReturnDate() within
I have written one controller class, in which i am writing one request mapping
I need to verify a password using reqex. I have written one and tested
I have written a simple CRUD form which has one select list. However the
I have written a code that draws grids and a triangle inside one grid
I have written a UITableView code in XCode. Once one of the cells is

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.