本文介绍了我想在asp.net的文本框中上传15张图片及其名称,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在asp.net上的文本框中上传15张图片及其名称,



图片和名称可能小于15,所以我想创建fileUpload动态控制和TextBox并在sql server 2008中存储图像路径和文本框值。

I want to upload 15 images and their Name from textbox in asp.net,

Images and Name are may be less than 15 so I want to create fileUpload control and TextBox dynamically and store Image path and textbox value in sql server 2008.

推荐答案

<body>
    <form id="form1" runat="server">
    <asp:Panel ID="Panel1" runat="server">
    </asp:Panel>
    <div>
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </div>
    <asp:Button ID="Button1" runat="server"

        Text="Button" OnClick="Btn_Click" />

    </form>
</body>







c#code






c# code

protected void Page_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < 5; i++)
            {
                Panel panel = new Panel();
                TextBox txt = new TextBox();
                txt.ID = "Textbx" + i;
                panel.Controls.Add(txt);
                Panel1.Controls.Add(panel);
            }
        }

        protected void Btn_Click(object sender, EventArgs e)
        {
            Label1.Text = "";
            for (int i = 0; i < 5; i++)
            {
                TextBox txt=(TextBox)Page.FindControl("Textbx"+i);
                Label1.Text =Label1.Text+ txt.Text + "<br />";
                
            }
        }





因为你只需要你不需要的图像路径上传它。你可以得到文件名。



我希望这是你的查询..



Over here since you need only the image path you dont have to upload it. You can get the filename.

I hope this is what your query is..



这篇关于我想在asp.net的文本框中上传15张图片及其名称,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 19:31