Click here to Skip to main content
15,884,425 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friend,

I have one user control UC1 which is register in another user control UC2.
In UC1 i have one drop down and i right onselectedindexchanged() event for same, but it is not raised when i change index of drop down.
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
              </asp:DropDownList>


protected void DropDownList1_SelectedIndexChanged (object sender, EventArgs e) 
{
//some functionality
}


but this event fired when i click on button which is on UC2

plz tell me why this is happend?
Posted
Updated 20-Dec-10 18:15pm
v2
Comments
Brij 20-Dec-10 10:49am    
Whether this dropdown is in some template?
Pank's 1986 21-Dec-10 0:03am    
Hi Brij,
No it is in user control.

When the autopostback is set True, after the page is rendered, a javascript is added on the onchange event of the dropdown (SELECT in HTML) to trigger the postback,

View the source after the page is rendered and check whether the javascript is getting added to the onchange event of the dropdown.

If you are adding some javascript on the onchange event of the dropdown in the code-behind, that might also stop the page to postback.
 
Share this answer
 
Comments
Pank's 1986 21-Dec-10 10:30am    
Thanks Imran I found solution, i added one javascript onchange function on same drop down.

Thanks Again
Imran Saiyed 21-Dec-10 10:37am    
welcome :)
amitavin_Sharma 8-Apr-13 2:02am    
please any one help me.....
i'm facing a problem
i used javascript methos to get dropdown list selected value named as "onchange" when i'm using this then SelectedIndexChanged Event not fired
plzzzzz help me
I can't say much reading yours description, but it looks like you need to set AutoPostBack property of DropDown to true.
This way page will make postback automatically when you change selected index.

In your case button clicking caused the page postback and then, if you changed selected index of your dropdown, DropDownList1_SelectedIndexChanged event if fired too.

If this is not a right solution, send yours markup and code so we can investigate whats happening.
 
Share this answer
 
Comments
Pank's 1986 21-Dec-10 0:11am    
I already set AutoPostBack="true" for drop down.
Martin Arapovic 21-Dec-10 10:07am    
Then something else is the problem, post controls code and page code where you are using them, then we can investigate whats happening. ;)
Pank's 1986 21-Dec-10 10:31am    
Hey martin,
i found solution, i added one javascript onchange function on same drop down.
because of that it will happen.

Thanks for reply
Setting AutoPostBack property of DropDown will do for you.
 
Share this answer
 
Comments
Pank's 1986 21-Dec-10 0:01am    
I set AutoPostBack property true
MrBatra 21-Dec-10 9:02am    
IS there any kind of error you're getting. Or Its just not working
Pank's 1986 21-Dec-10 10:32am    
i found solution, i added one javascript onchange function on same drop down. because of that it will happen.
Now its working

Thanks
MrBatra 21-Dec-10 15:31pm    
Good for you

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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