Content page:
protected void Page_Load(object sender, EventArgs e) { string gs = ConfigurationManager.ConnectionStrings["ging"].ConnectionString; if (Master.showCheck(s)) { //do something... } } MasterPage:
string gs = ""; protected void Page_Load(object sender, EventArgs e) { gs = ConfigurationManager.ConnectionStrings["ging"].ConnectionString; } public bool showCheck(string strID) { string strCheckIfParentExist = @""; using (SqlConnection scConn = new SqlConnection(gs)) { scConn.Open(); //throws an error: 'The ConnectionString property has not been initialized' } } Why do I receive the following error: The ConnectionString property has not been initialized
gshas no value. Some debugging would be able to check that.gsset in the page load for the MasterPage. Do I need to add another one inside theshowCheck()function?web.config?