Click here to Skip to main content
15,882,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
my problem is when i fire SelectedIndexChanged event of ddlmodalitylist asynchronously(ajax call) then javascript load event is not fired..thats y i have to fire onload event from server side.

window.onload = body_Onload;

     function body_Onload() {
        //javascript code

protected void ddlModalityList_SelectedIndexChanged(object sender, EventArgs e)
            ListItem selectedPair = ddlModalityList.SelectedItem;
            string str= selectedPair.Value;

           int ID= Convert.ToInt32(str);

           if (ID == -1)
              // ddlStudy.Items.Clear();

            strSQL = "SELECT Study_ID,Study_Desc FROM Study_Master WHERE Modality_ID='" + ID + "'";
            DataTable dataTableStudy = null;
            dataTableStudy = objSqlDbComm.ExecuteDatasetQuery(strSQL).Tables[0];

            var dictioneryStudy = new Dictionary<int,>();
            foreach (DataRow dr in dataTableStudy.Rows)

                dictioneryStudy.Add(Convert.ToInt32(dr["Study_ID"]), dr["Study_Desc"].ToString());

            ddlStudy.DataTextField = "Value";
            ddlStudy.DataValueField = "Key";
            ddlStudy.DataSource = dictioneryStudy;
            ddlStudy.Items.Insert(0, new ListItem("[Select]", "-1"));
            ddlStudy.Items[0].Selected = true;

Updated 4-May-12 2:18am

1 solution

Are you use the Triggers in your code?if not the use triggers in under the UpdatePanel tag after ContentTemplate
for Example:
asp:AsyncPostBackTrigger ControlID="ddlmodalitylist " EventName="SelectedIndexChanged"
Share this answer
[no name] 4-May-12 10:30am    
yes i am using Triggers
asp:AsyncPostBackTrigger ControlID="ddlmodalitylist " EventName="SelectedIndexChanged"

but i have to fire onload javascript event after SelectedIndexChangedevent fire
[no name] 4-May-12 10:31am    
because it is not load javascript after SelectedIndexChangedevent fire

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900