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.

JavaScript
window.onload = body_Onload;

     function body_Onload() {
        //javascript code
       }


C#
protected void ddlModalityList_SelectedIndexChanged(object sender, EventArgs e)
        {
            ddlStudy.Items.Clear();
            ListItem selectedPair = ddlModalityList.SelectedItem;
            string str= selectedPair.Value;

           int ID= Convert.ToInt32(str);

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


            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.DataBind();
            ddlStudy.Items.Insert(0, new ListItem("[Select]", "-1"));
            ddlStudy.Items[0].Selected = true;

        }
Posted
Updated 4-May-12 2:18am
v2

1 solution

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

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