Link to home
Start Free TrialLog in
Avatar of Relegence
RelegenceFlag for Israel

asked on

DropDownList doesn't generate a PostBack event 'OnSelectedIndexChanged'

Hello,

I am writing a c# asp.net application. I have a page with a DropDownList with AutoPostBack set to 'true'.
There is a case where, on the client side, I reset the DropDownList from another page:
parent.frames[0].document.getElementById('ddlGroups').selectedIndex = 0;

after that, I can't select the previous item in the DropDownList anymore - the postback doesn't happen.
Is it because I have changed the index from the client side?
How can I fix that?

Maybe I should reset the DropDownList on the server side. If so, Is it possible to reference a control from a different page?

Thanks
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

If you are working with 2.0, there is the PreviousPage property that lets you access public properties on a page.

Bob
Avatar of Relegence

ASKER

Can you please give an example of how to reference a control in another page using PreviousPage?
Example:

        if (this.PreviousPage != null && this.PreviousPage.IsCrossPagePostBack)
        {
            TextBox txt = (TextBox)this.PreviousPage.FindControl("TextBox1");

            if (txt != null)
            {
                this.TextBox1.Text = txt.Text;
            }
            this.PopupWindow1.Visible = false;
        }

Bob
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial