protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request.QueryString["ajax"])) { WebMethods.Process(); return; } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!string.IsNullOrEmpty(Request.QueryString["ajax"])) { _IsAjaxRequest = true; WebMethods.Process(); //Response.End(); return; } }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request.QueryString["ajax"])) { WebMethods.Process(); //Response.End(); return; } //System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(); //conn.ConnectionString= @"Data Source=207.56.187.6,1433\SQLExpress1;Initial Catalog=dxdpho;User Id=dxdphosql;Password=dxdpho;"; //try //{ // conn.Open(); // Response.Write("Connection is OK!"); //} //catch(System.Exception ex) //{ // Response.Write(ex.Message); //} //conn.Dispose(); }
protected void Page_Load(object sender, EventArgs e) { //string FILE_ID = "fileToUpload"; string FILE_ID = Request.QueryString["name"]; string photoType = Request.QueryString["ptype"]; int photoId = int.Parse(Request.QueryString["pid"]); AjaxResult ar = new AjaxResult { ReturnCode = 0, Message = string.Empty }; if (Request.Files[FILE_ID] == null || Request.Files[FILE_ID].ContentLength == 0) { ar.Message = "No file found"; ar.ReturnCode = 1; } else { HttpPostedFile file = Request.Files[FILE_ID]; string fileName = Guid.NewGuid().ToString() + file.FileName.Substring(file.FileName.LastIndexOf(".")); string folder = Server.MapPath(TARGET_FOLDER); string combined = string.Empty; if (folder.EndsWith("\\")) { combined = folder + fileName; } else { combined = folder + "\\" + fileName; } try { //if (folder.EndsWith("\\")) //{ // file.SaveAs(folder + fileName); //} //else //{ // file.SaveAs(folder + "\\" + fileName); //} file.SaveAs(combined); ar.Message = fileName; // update db Utility.UpdatePhotoFile(photoId, fileName, photoType); if (photoType.Equals("s2")) { Utility.UpdatePhotoSize(combined); System.Drawing.Size photoSize = Utility.GetPhotoSizeById(photoId); ar.Json = "{" + string.Format("\"width\":{0},\"height\":{1}", photoSize.Width, photoSize.Height) + "}"; } } catch (System.Exception ex) { ar.ReturnCode = 2; ar.Message = ex.Message + " and the file name is :" + combined.Replace("\\", "\\\\"); ar.Message.Replace("\\", "?"); } } //Response.ContentType = "application/x-javascript;charset=UTF-8"; Response.Clear(); WebMethods.OutputResult(ar); Response.End(); }