protected void page_load(object sender, eventargs e) { button cmdtemp = null; try { cmdtemp = (button)getpostbackcontrol(this); } catch { } filltabledb(); if(ispostback) { if(cmdtemp == null || cmdtemp.id == "btnnew" || cmdtemp.id != "btnsave") { generateblanktablehtml(""); } } } private void filltabledb() { //sql query //select status table generateblanktablehtml(status) } private void generateblanktablehtml(string status) { if(status=="") { btnnew.style.add("display", "none"); } else { //show status in label lblstatus.text=status; } } public static control getpostbackcontrol(page page) { control control = null; string ctrlname = page.request.params.get("__eventtarget"); if(ctrlname != null && ctrlname != string.empty) { control = page.findcontrol(ctrlname); } else { foreach(string ctl in page.request.form) { control c = page.findcontrol(ctl); if(c system.web.ui.webcontrols.button) { control = c; break; } } } return control; }
aspx:
<asp:button id="btnsave" runat="server"/> <asp:button id="btnnew" runat="server"/> <asp:label id="lblstatus" runat="server"
i have 2 functions filltabledb();generateblanktablehtml(string status); when status getting blank have hide btnnew otherwise showing status in label. if label having status , new study botton displayed otherwise not.
what want when user click on button new , have show label text blank status not click on save button should do.
try if(ispostback) { if(btnnew.style.value == "display:none;") { generateblanktablehtml(""); } } protected void btnnew_click(object sender, eventargs e) { generateblanktablehtml(""); }
Comments
Post a Comment