2014-02-18 2 views
0

AjaxFileUpload1의 pageupload 이벤트 동안 페이지의 텍스트 상자에서 변수에 값을 할당하고 있습니다. 문제는 텍스트 상자에서 값을 가져 오지 못하는 것입니다. 변수 오류 throws.My 변수는 없더라도텍스트 상자 값을 읽을 수 없습니다

 string scn = txtSCN.Text; 
     string line1 = txtLineitem.Text; 
     string aging1 = txtAging.Text; 

AjaxFileUpload1_UploadComplete 텍스트 상자의 값을 읽을 수없는 이유 어떤 생각

내 CS 코드는 다음과 같습니다

protected void AjaxFileUpload1_UploadComplete(object sender,  AjaxControlToolkit.AjaxFileUploadEventArgs e) 
     { 
    string c = System.IO.Path.GetFileName(e.FileName); 
     string dpath = "~/Profile/Images/"; 
     string scn = txtSCN.Text; 
     string line1 = txtLineitem.Text; 
     string aging1 = txtAging.Text;    
     AjaxFileUpload1.SaveAs(MapPath(Path.Combine(dpath,c))); 
     dpath = dpath + c; 
     string str1 = ConfigurationManager.ConnectionStrings["ProTracConnGMCH"].ConnectionString; 
     SqlConnection cn = new SqlConnection(str1); 
     cn.Open(); 
     string sql = "Update tbNoquoteFollowupupdate set MailreceivedURL = '" + dpath + "', chkMailreceived = 1 , Buyername = '" + buyername + "' where scn = '" + scn + "' AND lineItem = '" + line1 + "' and Aging ='" + aging1 + "' "; 
     SqlCommand cmd = new SqlCommand(sql, cn); 
     int i = cmd.ExecuteNonQuery(); 

     if (i > 0) 
     { 
      // AjaxFileUpload1.SaveAs(Path.Combine(dpath, e.FileName)); 
      //AjaxFileUpload1.SaveAs(MapPath(dpath)); 
     } 
     cn.Close(); 
     BindGridviewData1(); 
     cn.Open(); 
     string cmd2 = "Insert Into tbMulitmailsreived (scn, lineItem,followupdate, Aging,MailreceivedURL) Values ('" + scn + "', '" + line1 + "','" + DateTime.Now + "','" + aging1 + "','" + dpath + "')"; 
     SqlCommand sqlCommand2 = new SqlCommand(cmd2, cn); 
     sqlCommand2.ExecuteNonQuery(); 
     cn.Close(); 
    } 

제발 도와주세요

+0

, 이 십자가가 아닌가? – Schuere

답변

0

나는 Page.IsPostBack을 코드에 추가해야한다고 생각합니다. 이

protected void AjaxFileUpload1_UploadComplete(object sender,  AjaxControlToolkit.AjaxFileUploadEventArgs e) 
{ 
    if(!Page.IsPostBack) 
    { 
     string c = System.IO.Path.GetFileName(e.FileName); 
     string dpath = "~/Profile/Images/"; 
     string scn = txtSCN.Text; 
     string line1 = txtLineitem.Text; 
     string aging1 = txtAging.Text;    
     AjaxFileUpload1.SaveAs(MapPath(Path.Combine(dpath,c))); 
     dpath = dpath + c; 
     string str1 = ConfigurationManager.ConnectionStrings["ProTracConnGMCH"].ConnectionString; 
     SqlConnection cn = new SqlConnection(str1); 
     cn.Open(); 
     string sql = "Update tbNoquoteFollowupupdate set MailreceivedURL = '" + dpath + "', chkMailreceived = 1 , Buyername = '" + buyername + "' where scn = '" + scn + "' AND lineItem = '" + line1 + "' and Aging ='" + aging1 + "' "; 
     SqlCommand cmd = new SqlCommand(sql, cn); 
     int i = cmd.ExecuteNonQuery(); 

     if (i > 0) 
     { 
     // AjaxFileUpload1.SaveAs(Path.Combine(dpath, e.FileName)); 
     //AjaxFileUpload1.SaveAs(MapPath(dpath)); 
     } 
     cn.Close(); 
     BindGridviewData1(); 
     cn.Open(); 
     string cmd2 = "Insert Into tbMulitmailsreived (scn, lineItem,followupdate, Aging,MailreceivedURL) Values ('" + scn + "', '" + line1 + "','" + DateTime.Now + "','" + aging1 + "','" + dpath + "')"; 
     SqlCommand sqlCommand2 = new SqlCommand(cmd2, cn); 
     sqlCommand2.ExecuteNonQuery(); 
     cn.Close(); 
    } 
} 
1

처럼이 question 조사를 지난 주에 약간의 시간을 보냈다 그러나 결국 이에 대한 쉬운 해결책을 찾을 수 없습니다. 이 질문에서 OP는 세션에 값을 저장하여 해결했지만이 작업을 수행하려면 여전히 일부 단계에서 다시 게시가 필요할 수 있습니다.

분명히 AjaxFileUpload 컨트롤이 컨텍스트 키 모음의 값을 전달할 계획 이었지만 분명히 implemented이었습니다. 이 question은 자신을 구현하는 방법을 설명합니다.

내가 동일한 주제의 주위에 또 다른 질문을보고하고, 영업 이익은 AsyncFileUpload 컨트롤을 사용하여 변경하여 그것을 해결하지만 수정 될 서 생각 ... 내가 여기에 장거리 슛 갈거야

관련 문제