c# - Is there any way to call SelectedIndexChanged.BeginInvoke or similar method? -




i have list of items want set cookie on page_load(). it's long web form on top of sharepoint. don't want call each method each control's event, that's i'm doing right now. in other words, don't need know method called each control within page, need invoke it.

*edit -- autopostback set true each control, , handle event in page load page.ispostback. read somewhere selectindexchanged event not fire pageload, that's why i've been investigating ugly work-arounds.

current code:

enter code here foreach (control c in gpc.getallcontrols(this.master.findcontrol("placeholdermain").controls))                 {                     if (c == null) continue;                     if (c textbox)                     {                         textbox t = (textbox)c;                         if (cookie.values[c.id] != null)                         {                             t.text = cookie.values[c.id];                         }                     }                     else if (c dropdownlist)                     {                         dropdownlist d = (dropdownlist)c;                         if (cookie.values[c.id] != null)                         {                             d.selectedindex = int.parse(cookie.values[c.id]);                              switch (c.id)                             {                                 case "dropdownlistcategory":                                     onchangecategory(sender, e);                                     break;                                 case "dropdownlistcontracttype":                                     dropdownlistcontracttype_selectedindexchanged(sender, e);                                     break;                                 case "dropdownlistitpurchase":                                     onchangeitpurchase(sender, e);                                     break;                                 case "dropdownlistservicecontract":                                     onchangeservicecontract(sender, e);                                     break;                                 case "dropdownlistpom":                                     onchangepomchoice(sender, e);                                     break;                 //etc.                             }                          }                      } 

some past attempts abandoned morning, each 1 within comment delimiters:

/*                             d.autopostback = true;                             d.selectedindex = 0;                              system.threading.thread t = new system.threading.thread(delegate() {                                 system.threading.thread.sleep(10);                                 d.selectedindex = int.parse(cookie.values[c.id]);                             });                             t.start();                             */                                 /* this.clientscript.registerstartupscript(                                    this.gettype(),                                    "validateandstore",                                    "<script language='javascript' type='text/javascript'>" +                                    "$('[id$=" + d.id + "]').prop('selectedindex',"+int.parse(cookie.values[c.id])+");" +                                     "</script>"); */                             /* this.clientscript.registerstartupscript(                                    this.gettype(),                                    "validateandstore",                                    "<script language='javascript' type='text/javascript'>" +                                    "$('[id$=" + d.id + "]').selectedindex=" + int.parse(cookie.values[c.id]) + ";" +                                     "__dopostback(ctl00_placeholdermain_" + d.id + ",'onchange');" +                                    "</script>");*/ 





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -