163K网站系统官方论坛's Archiver

lufang 发表于 2007-2-16 12:01

.net教程:图片上传的webform(自动生成所略图)

[size=3]<%@ page language="c#" codebehind="feuploadpic.aspx.cs" autoeventwireup="false" inherits="cj168.web.mag.admins.fedata.feuploadpic" %>
<%@ register tagprefix="cj168" tagname="header" src="modules/headerfe.ascx" %>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en" >
<html>
    <head>
        <title>fedata</title>
        <meta content="microsoft visual studio 7.0" name="generator">
        <meta content="c#" name="code_language">
        <meta content="javascript" name="vs_defaultclientscript">
        <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetschema">
        <style>body { font-size: 9pt }
    .calpicdate { font-size: 9pt; font-family: verdana, helvetica, sans-serif }
    .valid { font-size: 9pt; color: red }
    td { font-size: 9pt }
        </style>
    </head>
    <body ms_positioning="gridlayout">
        <table width="100%">
            <tr>
                <td><cj168:header id="header1" runat="server"></cj168:header></td>
            </tr>
        </table>
        <form id="fedata" method="post" enctype="multipart/form-data" runat="server">
            <table id="table1" cellspacing="0" cellpadding="1" width="750" border="1">

                <tr>
                    <td width="70">图片标题</td>
                    <td><asp:textbox id="txtboxpictitle" runat="server"></asp:textbox><br>
                        <asp:requiredfieldvalidator id="requiredfieldvalidator1" runat="server" errormessage="请填写图片标题。" cssclass="valid" controltovalidate="txtboxpictitle"></asp:requiredfieldvalidator><br>

                        <asp:regularexpressionvalidator id="vldcatname" errormessage="图片标题至少2个字符,不应包含'“ ” ! @ # $ % ^ & * ( ) < > 《 》{ } [ ] ? 。,? ¥" cssclass="valid" controltovalidate="txtboxpictitle" validationexpression="[^'^“^”^\^!^@^#^$^%^\^^&^*^(^)^<^>^《^》^?^。^,^?^¥^\{^\}^\][^\]]{2,}" runat="server"></asp:regularexpressionvalidator></td>

                </tr>
                <tr>
                    <td>图片日期</td>
                    <td><asp:textbox id="txtboxpicdate" runat="server" width="300"></asp:textbox><asp:calendar id="calpicdate" runat="server" cssclass="calpicdate" width="300" selectmonthtext="本月" selectweektext="本周" nextprevformat="fullmonth" onselectionchanged="caldateselected">
                            <nextprevstyle cssclass="calpicdate"></nextprevstyle>
                            <weekenddaystyle forecolor="red"></weekenddaystyle>
                            <todaydaystyle font-bold="true" forecolor="red" backcolor="#ccccff"></todaydaystyle>
                            <selecteddaystyle backcolor="black" font-bold="true"></selecteddaystyle>
                        </asp:calendar><br>
                        <asp:requiredfieldvalidator id="requiredfieldvalidator2" runat="server" errormessage="请选择或填写图片日期。" cssclass="valid" controltovalidate="txtboxpicdate"></asp:requiredfieldvalidator><br>

                        <asp:customvalidator id="customvalidator1" errormessage="不是个有效的日期格式" cssclass="valid" controltovalidate="txtboxpicdate" runat="server" onservervalidate="servervalidatecheckdate"></asp:customvalidator></td>
                </tr>
                <tr>
                    <td>图片分类</td>
                    <td><asp:dropdownlist id="ddlpictype" runat="server" datavaluefield="fepictypeid" datatextfield="title"></asp:dropdownlist><font face="宋体"> </font><asp:regularexpressionvalidator id="regularexpressionvalidator1" errormessage="请选择图片分类" cssclass="valid" controltovalidate="ddlpictype" validationexpression="[^0]{1,}" runat="server"></asp:regularexpressionvalidator></td>
                </tr>
                <tr>
                    <td>图片介绍</td>
                    <td><asp:textbox id="txtboxpicintro" runat="server" maxlength="255" textmode="multiline" columns="50" rows="5"></asp:textbox>
                        <asp:regularexpressionvalidator id="regularexpressionvalidator2" runat="server" cssclass="valid" errormessage="内容中不应包含 ' <  >" controltovalidate="txtboxpicintro" validationexpression="[^'^<^>]{0,}"></asp:regularexpressionvalidator>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">(支持文件格式:jpg, gif, png)</td>
                </tr>
            </table>
            <table cellspacing="0" width="750" border="1">
                <tr>
                    <td width="70">图片名称</td>

                    <td width="300"><input title="浏览" type="file" size="25" name="filepicname" runat="server" id="filepicname">
                        <asp:regularexpressionvalidator id="regularexpressionvalidator3" runat="server" cssclass="valid" errormessage="文件名只能由字母或数字组成,不能包含 - _ 等其他符号长度至少为1" controltovalidate="filepicname" validationexpression="[ :.\\a-za-z0-9]{1,}"></asp:regularexpressionvalidator>
                    </td>
                    <td><asp:checkboxlist id="checkboxlistrewrite" runat="server" borderwidth="0" height="100%" cellpadding="5" repeatlayout="table" repeatcolumns="1" repeatdirection="vertical">
                            <asp:listitem value="1">覆盖原有图片</asp:listitem>
                        </asp:checkboxlist></td>
                </tr>
            </table>
            <table cellspacing="0" width="750" border="1">
                <tr>
                    <td align="middle"><asp:button id="btnsubmit" onclick="uploadfile" runat="server" text="确定"></asp:button></td>
                </tr>
                <tr>
                    <td><asp:label id="lblpicinfo" runat="server">label</asp:label></td>
                </tr>
                <tr>
                    <td><font face="宋体"></font>
                    </td>
                </tr>

            </table>
        </form>
        <asp:hyperlink id="hlkoripic" runat="server">原图</asp:hyperlink>
        <asp:hyperlink id="hlknewpic" runat="server">缩略图</asp:hyperlink>
    </body>
</htm



[/size]

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.