Hi,
I'm having a problem ... and it may be related to the ID of the combo was renamed dynamically due to a partial post back.
I have a Page which has a Combo Box A showing my provinces, In this page I call a dynamic user control which is refreshed everytime Combo Box A is changed.
In my UC, I have another Combo Box B ( the problematic Combo) and on this UC ( Page_Init) I inject a JS in which i have the following snippet
As you can see, I replace the ClientID, and on first load of the page, this is resolved correctly like ctl00_PrincipalPlaceHolder_ctl00_cmbSearchType but when I change Combo A, it reload the user control, which in turn reload the script above. In the rendered HTML, The COmbo ID is renamed to ctl00_PrincipalPlaceHolder_ctl01_cmbSearchType (Note the subtle change in name from ct00 to ct01 ) In my debug, I saw this ClientID contain the new ID but somehow it is not replaced regenrated on the rendered html.
I guess my question is how do i force the JS to be re-rendered every time this UC is called? For some reason, it is always using the original rendered JS ( which is why it is working the first time)
Thanks
I'm having a problem ... and it may be related to the ID of the combo was renamed dynamically due to a partial post back.
I have a Page which has a Combo Box A showing my provinces, In this page I call a dynamic user control which is refreshed everytime Combo Box A is changed.
In my UC, I have another Combo Box B ( the problematic Combo) and on this UC ( Page_Init) I inject a JS in which i have the following snippet
string jsFunction =
@"
//Search TAB
//cmbSearchType - shows relevant input fields
function DefineView(sender, eventArgs) {
var comboSearch = $find('%%cmbSearchType%%');
//cmbSearch Section
switch (comboSearch.get_selectedItem().get_value()) {
[[MY CODE HERE]
}
}
function onPageLoad(){
$(document).ready(function(){
DefineView();
});
}";
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "SearchVisibilityPPSA",jsFunction.Replace("%%cmbSearchType%%", cmbSearchType.ClientID),true);
string onLoadScript = @"Sys.Application.add_load(function(){ onPageLoad();})
";
ScriptManager.RegisterStartupScript(this, this.GetType(), "onLoadScript", onLoadScript, true);
As you can see, I replace the ClientID, and on first load of the page, this is resolved correctly like ctl00_PrincipalPlaceHolder_ctl00_cmbSearchType but when I change Combo A, it reload the user control, which in turn reload the script above. In the rendered HTML, The COmbo ID is renamed to ctl00_PrincipalPlaceHolder_ctl01_cmbSearchType (Note the subtle change in name from ct00 to ct01 ) In my debug, I saw this ClientID contain the new ID but somehow it is not replaced regenrated on the rendered html.
I guess my question is how do i force the JS to be re-rendered every time this UC is called? For some reason, it is always using the original rendered JS ( which is why it is working the first time)
Thanks