<%@ Page Language="C#" MasterPageFile="~/themes/Default/Site.Master" AutoEventWireup="true"
    EnableViewState="false" CodeBehind="Add.aspx.cs" Inherits="Aspx1.Add" Title="发布源码出售信息"
    ValidateRequest="false" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="id_w main">
        <div class="li_l" style="width: 790px;">
            <div class="box_l Path">
                <a href="/">首页</a> >> <a href="/Add.aspx">发布源码</a>
            </div>
            <div class="clear_left">
            </div>
            <table cellspacing="0" cellpadding="0" border="0">
                <tr>
                    <td height="25" width="30%" align="right">
                        <b>源码名称：</b>
                    </td>
                    <td height="25" width="*" align="left">
                        <asp:TextBox ID="txtTitle" runat="server" Width="200px"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txttitle"
                            ErrorMessage="源码名称怎么可能为空！"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td height="25" width="30%" align="right">
                        <b>源码类别：</b>
                    </td>
                    <td height="25" width="*" align="left">
                        <asp:DropDownList ID="ddlCategory" runat="server" DataSourceID="ObjectDataSource1"
                            DataTextField="CategoryName" DataValueField="CategoryID">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td height="25" width="30%" align="right">
                        <b>演示地址：</b>
                    </td>
                    <td height="25" width="*" align="left">
                        <asp:TextBox ID="txtURL" runat="server" Width="200px" Text="http://"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td height="25" width="30%" align="right">
                        <b>系统标签：</b>
                    </td>
                    <td height="25" width="*" align="left">
                        <asp:Label ID="lblSysTags" runat="server" Text=""></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td height="25" width="30%" align="right">
                        <b>自定义标签：</b>
                    </td>
                    <td height="25" width="*" align="left">
                        <asp:TextBox ID="txtTags" runat="server" Width="285px"></asp:TextBox><br />
                        (多个标签之间请用空格分隔，每个标签最长8个字符，最多4个标签)
                    </td>
                </tr>
                <tr>
                    <td height="25" width="30%" align="right">
                        <b>源码介绍：</b>
                    </td>
                    <td align="left">
                        <input type="hidden" name="description" id="description" value="" />
                        <iframe id="myiframe" src="Images/Editor/editor.htm?id=description&ReadCookie=0"
                            frameborder="0" scrolling="no" width="700px" height="460px"></iframe>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <b>源码截图:</b>
                    </td>
                    <td align="left">
                        注：截图只支持：jpg,gif,png,bmp四种格式）
                        <div id="myFile">
<div id="attach1"><span id="attach_s1"></span><input type="file" name="file_1" id="file_1" onchange="attach_change();" />描述:<input type="text" name="filedesc_1" id="filedesc_1" /></div>
                        </div>

                        <script type="text/javascript">
var aid = 0;
var id = 1;
function attach_change()
{
if(aid >5) {alert('最多只能上传5个附件！');return ;} 
var extensions = 'jpg,gif,png,bmp';  
var obj = $('file_'+id);
var path = obj .value;
var ext = path.lastIndexOf('.') == -1 ? '' : path.substr(path.lastIndexOf('.') + 1, path.length).toLowerCase();
var re = new RegExp("(^|\\s|,)" + ext + "($|\\s|,)", "ig");
if(path ==''){return;} 
if(extensions != '' && (re.exec(extensions) == null || ext == '')) 
{
obj.value="";
alert('对不起，不支持上传此类扩展名的附件。');
return;
}
var newNode = $("attach"+id).cloneNode(true);

obj.style.display="none";
obj = document.createElement("a");
obj.href = "javascript:attach_del(" +id+ ")";
obj.innerHTML = "[删除]";
$("attach"+id).appendChild(obj);
$("attach_s"+id).innerHTML="源码截图："+path.substr(path.lastIndexOf("\\")+1);

id++;
newNode.id = "attach" + id;
newNode.childNodes[0].id="attach_s"+id
newNode.childNodes[1].name = "file_" +id;
newNode.childNodes[1].id = "file_" +id;
newNode.lastChild.name = "filedesc_"+id;

$('myFile').appendChild(newNode);
aid++;
}
function attach_del(id){
var theNode = $('attach'+id);   
$('myFile').removeChild(theNode);
aid--;
}
                        </script>

                    </td>
                </tr>
                <tr>
                    <td height="25" width="30%" align="right">
                        <b>价格：</b>
                    </td>
                    <td height="25" width="*" align="left">
                        <asp:TextBox ID="txtPrice" runat="server" Width="61px" Text="1" onKeyUp="isNumber(this);"></asp:TextBox>
                        &nbsp;元<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtprice"
                            ErrorMessage="不填写价格，准备白送？"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td height="25" width="30%" align="right">
                        <b>联系QQ：</b>
                    </td>
                    <td height="25" width="*" align="left">
                        <asp:TextBox ID="txtQQ" runat="server" onKeyUp="isNumber(this);"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td height="25" width="30%" align="right">
                        <b>邮箱：</b>
                    </td>
                    <td height="25" width="*" align="left">
                        <asp:TextBox ID="txtMail" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td height="25" width="30%" align="right">
                        <b>联系电话：</b>
                    </td>
                    <td height="25" width="*" align="left">
                        <asp:TextBox ID="txtTel" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td height="25" colspan="2" align="center">
                        <asp:Button ID="btnAdd" runat="server" Text="· 提交 ·" OnClick="btnAdd_Click"></asp:Button>
                        <input type="reset" value="· 重填 ·" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetVisibleList"
        TypeName="Aspx1.BLL.ProductCategory"></asp:ObjectDataSource>
</asp:Content>
