asp.net - ScriptManager.RegisterStartUpScript(...) not working -
i've used command since start new project on imagebutton_click event, , it's working perfect in every page i'm using this: first, check if there's field empty if yes send alert.
scriptmanager.registerstartupscript(this, typeof(page), "alert", "alert('no empty fields allowed.');", true); what i'm doing here: have 2 textboxes type 2 dates, these dates used fill reportviewer, before goes reportviewer, check if it's empty or not.
in page it's working in first time press button. used breakpoint, , it's passing ok throught conditional if, it's not showing message... why?
full code on button_click event:
if (txt_dt_final.text == "" || txt_dt_inicial.text == "") { scriptmanager.registerstartupscript(this, typeof(page), "alert", "alert('no empty fields allowed.');", true); txt_dt_inicial.focus(); return; } update
actually, after press first time, nothing works anymore... if type valid date, not working... tested and, error appears, if error hapens first time press button.
e.g.:
if type dates ok, reportviewer return me result of report... click on button empty textboxes, fire error , show me message. if press again work fine !
now, if press button empty fields first time, button not work anymore ! working if refresh page... why ? o.o
others pages working perfect.
your code should work unless have asp controls inside update panel. if use instead.
scriptmanager.registerstartupscript(updatepanel,updatepanel.gettype() , "alert", javascript, true);
Comments
Post a Comment