c# - How to pass value in a constructor to enable or disable a button in asp.net control? -


i having constructor on user control main page reinitialize user control.

i tried

//constructor

 usercontrol(isnew)   {     this.btnadd.enabled=true;    } 

btnadd (aspx button runat server) control want disable.

while compiling not shows error.but while runtime throws error saying btnaddis null. object reference not set instance of object. btnadd. thnaks

use page_init event , property.

[browsableattribute(true)] [defaultvalue("true")] public bool isnew { get; set; }  protected void page_init(object sender, eventargs e) {     btnadd = isnew; } 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -