您的位置:程序门 -> web 开发 -> ajax



请高手指点,点上传没有反应。谢谢!


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


请高手指点,点上传没有反应。谢谢!
发表于:2007-04-17 17:06:04 楼主
<%@   page   language= "c# "   autoeventwireup= "true "   codefile= "loadimg_test.aspx.cs "   inherits= "manage_loadimg_test "   %>

<!doctype   html   public   "-//w3c//dtd   xhtml   1.0   transitional//en "   "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd ">

<html   xmlns= "http://www.w3.org/1999/xhtml "   >
<head   runat= "server ">
        <title> 无标题页 </title>
</head>
<body>
        <form   id= "form1 "   runat= "server ">
        <div>
                <asp:scriptmanager   id= "scriptmanager1 "   runat= "server ">
                </asp:scriptmanager>
                <asp:updatepanel   id= "updatepanel1 "   runat= "server ">
                        <contenttemplate>
                <asp:image   id= "image_move "   runat= "server "   height= "336px "   width= "643px "   imageurl= "~/images/upimg/1.bmp "   /> <br   />
        <div>
                <asp:fileupload   id= "fileupload_move "   runat= "server "   />
                <asp:button   id= "btn_upload "   runat= "server "   text= "上传 "   width= "59px "   onclick= "btn_upload_click "   /> <br   />
                <asp:label   id= "label1 "   runat= "server "   text= "label "> </asp:label> </div>
                </contenttemplate>                    
                </asp:updatepanel>
                <br   />
                &nbsp;
       
        </div>
        </form>
</body>
</html>


using   system;
using   system.data;
using   system.configuration;
using   system.collections;
using   system.web;
using   system.web.security;
using   system.web.ui;
using   system.web.ui.webcontrols;
using   system.web.ui.webcontrols.webparts;
using   system.web.ui.htmlcontrols;

public   partial   class   manage_loadimg_test   :   system.web.ui.page
{
        protected   void   page_load(object   sender,   eventargs   e)
        {

        }      
        protected   void   btn_upload_click(object   sender,   eventargs   e)
        {
                boolean   fileok=false;
                string   name=this.fileupload_move.filename;
                //string   size=this.fileupload_move.postedfile.contentlength.tostring();
                //string   type=this.fileupload_move.postedfile.contenttype;
                //string   type2;
                string   ipath   =   server.mappath( "~/images/upimg/ "+name);
                //string   fpath   =   server.mappath( "~/images/upfile/ "+name);
                //string   wpath   =   "~/images/upimg/ "   +   name;
                if   (this.fileupload_move.hasfile)
                {
                        string   fileextension   =   system.io.path.getextension(this.fileupload_move.filename).tolower();
                        string[]   allowedextensions   ={ ".gif ", ".png ", ".jpeg ", ".jpg ", ".bmp "};
                        for   (int   i   =   0;   i   <   allowedextensions.length;   i++)
                        {
                                if   (fileextension   ==   allowedextensions[i])
                                {
                                        fileok   =   true;
                                }
                        }
                        if   (fileok)
                        {
                                try
                                {
                                        this.fileupload_move.postedfile.saveas(ipath);
                                        this.image_move.imageurl   =   "~/images/upimg/ "+name;
                                        this.label1.text= "上传成功! ";
                                }
                                catch
                                {
                                        this.label1.text   =   "上传失败! ";
                                }
                                }
                        }
        }
}
发表于:2007-04-17 17:24:101楼 得分:0
点‘上传'控件后this.fileupload_move里面的内容被清空,麻烦大哥帮个忙?初次使用ajax


快速检索

最新资讯
热门点击