This means that somewhere in your call chain you tried to access a Property or call a method on an object that was null .
Given your statement:
img1.ImageUrl = ConfigurationManager .AppSettings .Get("Url") .Replace("###", randomString) + Server.UrlEncode( ((System.Web.UI.MobileControls.Form)Page .FindControl("mobileForm")) .Title);
I assume that calling AppSettings.Get("Url") returns null because the value is not found, or calling Page.FindControl("mobileForm") returns null because the control was not found.
You can easily break this down into several statements to solve the problem:
var configUrl = ConfigurationManager.AppSettings.Get("Url"); var mobileFormControl = Page.FindControl("mobileForm") as System.Web.UI.MobileControls.Form; if(configUrl != null && mobileFormControl != null) { img1.ImageUrl = configUrl.Replace("###", randomString) + mobileControl.Title; }
Justin niessner
source share