protected void btnAddRefer_OnClick(object sender, EventArgs e) { var usernaMe = Session["username"].ToString(); var studNo = nav.studentsRegister.ToList() .Where(s => s.Username == Session["username"].ToString()) .Select(sn => sn.No) .SingleOrDefault(); var refFname = txtrefFname.Text.Trim(); var refmname = refMidName.Text.Trim(); var refLname = refLName.Text.Trim(); var refemail = refEmail.Text.Trim(); var ferPhneNo = refMobile.Text.Trim(); var mobileBuilder = new StringBuilder(ferPhneNo); mobileBuilder.Remove(0, 1); //Trim one character from position 1 mobileBuilder.Insert(0, "+254"); // replace position 0 with +254 ferPhneNo = mobileBuilder.ToString(); try { var credentials = new NetworkCredential(ConfigurationManager.AppSettings["W_USER"], ConfigurationManager.AppSettings["W_PWD"], ConfigurationManager.AppSettings["DOMAIN"]); var nws = new Portals(); nws.Credentials = credentials; nws.PreAuthenticate = true; nws.FnAddReferee(usernaMe, studNo, refFname, refmname, refLname, ferPhneNo, refemail); KCDFAlert.ShowAlert("Referee Added Successfully!"); loadRefs(); txtrefFname.Text = ""; refMidName.Text = ""; refLName.Text = ""; refEmail.Text = ""; refMobile.Text = ""; } catch (Exception ep) { KCDFAlert.ShowAlert(ep.Message); } }