1.多个File Field,像sohu2.DROPDOWNLIST有个add

解决方案 »

  1.   

    只能用javascript来实现类似的功能,相当于用javascript定制一个自己的Html控件.我以前做过一个你需要的这种东西,一个html文件(作为模式窗口来用),如果你要就把mail留下。
      

  2.   

    Public Class FileOpenDialogInWebForm
        Inherits System.Windows.Forms.UserControl#Region " Windows Form Designer generated code "    Public Sub New()
            MyBase.New()        'This call is required by the Windows Form Designer.
            InitializeComponent()        'Add any initialization after the InitializeComponent() call    End Sub    'UserControl1 overrides dispose to clean up the component list.
        Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                If Not (components Is Nothing) Then
                    components.Dispose()
                End If
            End If
            MyBase.Dispose(disposing)
        End Sub    'Required by the Windows Form Designer
        Private components As System.ComponentModel.IContainer    'NOTE: The following procedure is required by the Windows Form Designer
        'It can be modified using the Windows Form Designer.  
        'Do not modify it using the code editor.
        Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
        Friend WithEvents Button1 As System.Windows.Forms.Button
        Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
        Friend WithEvents Button2 As System.Windows.Forms.Button
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
            Me.TextBox1 = New System.Windows.Forms.TextBox()
            Me.Button1 = New System.Windows.Forms.Button()
            Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog()
            Me.Button2 = New System.Windows.Forms.Button()
            Me.SuspendLayout()
            '
            'TextBox1
            '
            Me.TextBox1.BackColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(192, Byte), CType(128, Byte))
            Me.TextBox1.Location = New System.Drawing.Point(8, 8)
            Me.TextBox1.Name = "TextBox1"
            Me.TextBox1.ReadOnly = True
            Me.TextBox1.Size = New System.Drawing.Size(216, 20)
            Me.TextBox1.TabIndex = 0
            Me.TextBox1.Text = ""
            '
            'Button1
            '
            Me.Button1.BackColor = System.Drawing.Color.Gray
            Me.Button1.ForeColor = System.Drawing.SystemColors.ControlLightLight
            Me.Button1.Location = New System.Drawing.Point(56, 40)
            Me.Button1.Name = "Button1"
            Me.Button1.Size = New System.Drawing.Size(144, 23)
            Me.Button1.TabIndex = 1
            Me.Button1.Text = "Open Document"
            '
            'Button2
            '
            Me.Button2.BackColor = System.Drawing.Color.Gray
            Me.Button2.ForeColor = System.Drawing.Color.White
            Me.Button2.Location = New System.Drawing.Point(232, 8)
            Me.Button2.Name = "Button2"
            Me.Button2.Size = New System.Drawing.Size(24, 23)
            Me.Button2.TabIndex = 2
            Me.Button2.Text = "..."
            '
            'FileOpenDialogInWebForm
            '
            Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button2, Me.Button1, Me.TextBox1})
            Me.Name = "FileOpenDialogInWebForm"
            Me.Size = New System.Drawing.Size(264, 72)
            Me.ResumeLayout(False)    End Sub#End Region    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            OpenFileDialog1.ShowDialog()
            TextBox1.Text = OpenFileDialog1.FileName
        End Sub    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            System.Diagnostics.Process.Start(TextBox1.Text)
        End SubEnd Class
      

  3.   

    客户端:<INPUT style="Z-INDEX: 119; LEFT: 435px; WIDTH: 153px; POSITION: absolute; TOP: 298px; HEIGHT: 21px" type="file" size="20"  id="uploadfile" runat="server">服务器:
    protected System.Web.UI.HtmlControls.HtmlInputFile Text1;
    protected System.Web.UI.WebControls.DropDownList myInputList;
    protected System.Web.UI.WebControls.Button btn_Upload;....private void btn_Upload_Click(object sender, System.EventArgs e)
    {
      ListItem items=new ListItem(Text1.Value.ToString(),Text1.Value.ToString());
      myInputList.Items.Add(Text1.Value);
    }多几个的话可以循环
      

  4.   

    TO storm97(风暴不再):
        THANK YOU!
        MY MAIL ADDRESS:[email protected]
      

  5.   

    TO  atian25(阿天):
        你的办法是可以,但是我在实行时发现添加的文件SERVER端必须存在,而且发送
    的也是SERVER端的文件。不知道这问题如何解决。
      

  6.   

    你的意思是想在客户端处理myInputList?
      

  7.   

    <input type=file id="file1" runat=server>
      

  8.   

    http://expert.csdn.net/Expert/topic/2062/2062788.xml?temp=.5953485
      

  9.   

    TO  atian25(阿天):
          发送的附件肯定是在客户的机子上的。
      

  10.   

    TO  atian25(阿天):
        不对,发送的服务器端的文件。
        下面是程序的一些设置:
        1,webform上放一个html的file field控件,并且是作为server控件的(如果不是代码就不能访问)。
        2,一个添加按钮,把file field控件读入的文件名追加到dropdownlist中。
           lstadd.Items.Add(File1.Value.ToString()); 
        3,发送按钮,把dropdownlist中的文件名追加到MailMessage并发送。
        //添付
        for(int i=0;i<lstadd.Items.Count;i++)
        mailobj.Attachments.Add(new MailAttachment(lstadd.Items[i].Value.ToString()));

    file field控件选择的确实是客户端的文件,可是发送时如果SERVER端没有该文件则出错,有则发送SERVER端的文件。
      

  11.   

    忘了说了,先要uploadfile.PostedFile.SaveAs(Filepath)上传到服务器
    sohu等应该就这样吧。下面2个可能对你有帮助支持SMTP服务器认证的邮件发送组件V1.0B(附源码) 
    http://www.aspxcn.com/dotnetdown/show.aspx?id=49WebService邮件发送服务系统(附源码,推荐)
    http://www.aspxcn.com/dotnetdown/show.aspx?id=67
      

  12.   

    TO  atian25(阿天):
        谢谢!
        这个问题解决了。20分奉上。