English 中文(简体)
下拉列表如何发现其选定的索引已更改,并需要触发选定的索引更改事件?
原标题:How dropdown find out that its selected index has changed and need to fire selected index changed event?
  • 时间:2011-02-17 11:39:59
  •  标签:
  • asp.net

下拉列表如何发现其选定的索引已更改,并需要触发选定的索引更改事件?

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.

所以我的问题是多普敦是如何发现它的选择指数发生了变化的。

问题回答

如果includeStagesBeforeSyncPoint为true,则OnSelectedIndexChanged似乎应该始终在DropDownList回发时激发

System.Web.UI页面

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);
}




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签