开发者

How dropdown find out that its selected index has changed and need to fire selected index changed event?

How dropdown find out that its selected index has changed and need to fire selected index changed event?

Suppose i have a dropdown which is bounded with objectdatasource and objectdatasource has following items opt1 opt2 opt3 opt4 then i added default value --select-- to objectdatasource, now dropdown is populated and i can see all the items on it. I have a button and on its client click, through java script i set opt4 to selected item. now if i select --select-- from dropdown then it does not fire selected index changed event but it fires dropdown's data bound event and then if i select any other value it fire both events and then if i again select --select-- then it fire both event, only first time if i select --select--then it will not fire selected index change event but if i select other than --select-- it fire both events开发者_StackOverflow社区.

So my question is how dorpdown find out that its selection index has changed.


It looks like OnSelectedIndexChanged should always fire on a DropDownList postback if includeStagesBeforeAsyncPoint is true

System.Web.UI.Page

private void ProcessRequestMain(bool includeStagesBeforeAsyncPoint, bool includeStagesAfterAsyncPoint) {
    if (includeStagesBeforeAsyncPoint) {
        ...
        if (this.IsPostBack) {
            ...
            this.RaiseChangedEvents();


internal void RaiseChangedEvents() {
    ...
    for (int i = 0; i < this._changedPostDataConsumers.Count; i++) {
        ...
        postBackDataHandler.RaisePostDataChangedEvent();
    }
}

System.Web.UI.WebControls.DropDownList

void IPostBackDataHandler.RaisePostDataChangedEvent()
{
    this.RaisePostDataChangedEvent();
}

protected virtual void RaisePostDataChangedEvent() {
    ..
    this.OnSelectedIndexChanged(EventArgs.Empty);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜