c# - How to change label text with click event -


i have label in called "lblnotify" in site.master(asp.net).

 *<div class = "notification">          <asp:label id="lblnotify" runat="server" text ="0 "></asp:label>            </div>*         

and in code behind file, have method supposed replace text of "lblnotify" another.

*public void notificationmanager()     {         try        {             string = lblnotify.text;             = + "new";             lblnotify.text = ;              label1.text = (i);         }        catch (exception er)         {             response.write("exception occured:   " + er);         }     }* 

notificationmanager triggered in submit button in class

*protected void btnsubmit_click(object sender, eventargs e)     {                      appsite call = new appsite();                           call.notificationmanager();      }* 

but gives me error object reference not set instance of object @

 *string = lblnotify.text;*  

in try block when comment try-catch , same error @

 *response.write("exception occured:   " + er);* 

in catch block when not comment try-catch. have tried can still error. appreciated.

i'm not sure going do!, controls initialized in init page life cycle , , thing can init label control in constructor of page class :

public appsite() {   lblnotify = new label(); } 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -