Tuesday, August 10, 2010

ModalPopup box Ajax Problem

Problem :
When you have two drop down (or any control) in ModalPopup box,
and by one's post back event you want another control's value need to bind or fill.
But if you are using ModalPopup box then there is two problem
1) SelectedIndexChanged event will not fire.
2) ModalPopup box Disappear.

Solution :
STEP 1:
Make your update pannel's update mode to conditional.
UpdateMode="Conditional"
STEP 2:
write down folloing JavaScript function in your page's Head section
function IndexChanged()
{
document.getElementById('<%= btnIndexChanged.ClientID %>').click();

}
STEP 3:
Make Dummy button and put it in below your drop down.


STEP 4 :
Write folloing code in your first drop down


STEP 5:
In your .CS code put folloing code
//CS Code
protected void drpGrade_SelectedIndexChanged(object sender, EventArgs e)
{
BindDrpFreind(Convert.ToInt32(drpGrade.SelectedValue));
mpAddFriend.Show();
}
Root Cause of Problem
ModalPopupBox is not able to capture postback event so we are calling one Javascript function and through that we call OnSelectedIndex changed of a drop down.
if you have any problem or query write me on viralpala@gmail.com


No comments:

Post a Comment