{
string path=Server.MapPath("Upcptp");
string y=DateTime.Now.Year.ToString();
string m=DateTime.Now.Month.ToString();
string d=DateTime.Now.Day.ToString();
string h=DateTime.Now.Hour.ToString();
string n=DateTime.Now.Minute.ToString();
string s=DateTime.Now.Second.ToString();
string filename=y+m+d+h+n+s;
Random r=new Random();
filename=filename+r.Next(1000);
filename=filename+"."+upload_file.PostedFile.FileName.Substring(upload_file.PostedFile.FileName.Length-3);
string FN="Upcptp/"+filename;
filename=path+"/"+filename;
upload_file.PostedFile.SaveAs(filename);

if (fileEXT=="gif")
{
Response.Write("<"+"script>window.parent.cp_edit.dlList__ct3_cptp.Text='"+FN+"'</"+"script>");
}
else if(fileEXT=="jpg")
{
Response.Write("<"+"script>window.parent.cp_edit.dlList__ct3_cptp.Text='"+FN+"'</"+"script>"); }

upload_file.Visible=false;
Button1.Visible=false;
Info.InnerHtml="成功上传一个文件点击 <a href=Upcptp.aspx>这儿</a> 继续上传";
Info.Visible=true;
}

else
{
Info.Visible=true;
}

}
我通过以上代码上传文件  为什么
if (fileEXT=="gif")
{
Response.Write("<"+"script>window.parent.cp_edit.dlList__ct3_cptp.Text='"+FN+"'</"+"script>");
}
else if(fileEXT=="jpg")
{
Response.Write("<"+"script>window.parent.cp_edit.dlList__ct3_cptp.Text='"+FN+"'</"+"script>"); }
这两句都没起作用这样写是否有错呢?

解决方案 »

  1.   

    通过JS来控制daltalist的item不知道是否可以,我没有测试!
    建议设置一个label来设置FN,
    并通过使用findcontrol来更改这个label的text属性
      

  2.   

    string nam = slavefile.PostedFile.FileName.Trim() ;
    int i= nam.LastIndexOf(".");
    string newext =nam.Substring(i).Trim ();
    if (newext == ".gif") 
    {
      Response.Write("<"+"script>window.parent.cp_edit.dlList__ct3_cptp.Text='"+FN+"'</"+"script>");}
    elseif((newext == ".jpg") )
    {
      Response.Write("<"+"script>window.parent.cp_edit.dlList__ct3_cptp.Text='"+FN+"'</"+"script>");
       
    }
    看看可不可以
      

  3.   

    为什么弄的那么复杂呢?
    建议看下这个:http://www.cnblogs.com/zxjnet/articles/23812.aspx
      

  4.   

    我要把上传的路径存FN存到cptp.text里 然后把这个保存到数据库里