是否有可能触发“选择文件上传"?对话框,带有单个asp按钮,而不使用JavaScript,Jquery和Ajax控件? [英] Is that possible to trigger "Choose file to Upload" dialogue box with single asp button without using JavaScript, Jquery and Ajax controls ?

查看:88
本文介绍了是否有可能触发“选择文件上传"?对话框,带有单个asp按钮,而不使用JavaScript,Jquery和Ajax控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当最终用户单击该按钮选择要上传的文件"对话框时,最终用户应该只能看到一个按钮,并且该按钮的文本应该是选择文件"或打开文件",而不是浏览..".

The end user should see only a single button and text of that button should be "choose file" or "open file" other than "browse.." when the end user click on that button "Choose file to Upload" dialogue box should trigger.Is that possible?

推荐答案

文件上传早在JQuery和AJAX普及之前就已经成为Web开发的一部分.您需要的只是具有type = file的输入元素

File uploading has been a part of web development long before JQuery and AJAX were popularized. The input element with type=file is all you need

<input id=''someId'' type=''file''/>


在下面的代码中,您可以看到有2个控件,一个是文件上传,另一个是按钮.

现在,通过将此CSS属性
In the below code u can see that there are 2 controls one is file upload and another one is a button.

Now by giving this CSS property
opacity: 0; filter: alpha(opacity=0)

设置为文件上传,我们可以将文件上传控件设置为不可见

我们都知道我们不能在File Upload控件中增加浏览按钮的宽度大小,因此要增加浏览按钮的宽度,我们会增加字体大小,因此文件上传中的浏览按钮将变得稍微宽一点.

现在缩小文件上传,直到文件上传中的文本框消失,确保将控件放置在

to file upload we can make file upload control as invisible

we all know that we cannot increase the width size of browse button in File Upload control so to increase the width of the browse button we increase the font size so the browse button in file upload will become little wider.

Now shrink the file upload until the text box in file upload gets disappear make sure that the controls are placed inside the

标记内,并且该div标记的溢出被隐藏.

现在,右键单击"Asp"按钮,然后将其发送回去(索引为-1).

通过将Asp按钮放在文件上传控件上方,将Asp按钮放在文件上传控件后面.

因此,当最终用户自然地单击该Asp按钮时,将单击位于按钮上方的文件上传控件,并会触发选择文件上传对话框"


tag and the overflow of that div tag is hidden.

Now Right-click on the Asp button and give send to back(index as -1).

By placing the Asp button over the file upload control Asp button will be placed behind the file upload control.

So when end user click on that Asp button naturally File upload control which is place over the button will be clicked and "Choose file to upload dialogue" box will be triggered


<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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>Untitled Page</title>
    <style type="text/css">
        #form1
        {
            height: 501px;
        }
    </style>
</head>
<body>
<div>
    <form id="form1" runat="server">

    <div style="height: 89px; width: 620px; position: relative; top: 226px; left: 229px; overflow:hidden">
        <asp:FileUpload ID="FileUpload1" runat="server"

            Style=" top:1px; left:-10px; width: 265px; position: relative; height: 26px; opacity: 0; filter: alpha(opacity=0)"

            Font-Size="30pt" />
        <asp:Button ID="Button1" runat="server" Text="Choose file.."

            Style="top: -5px; left:-265px; z-index: -1; width: 251px; position: relative;"

            Height="22px" />
    </div>

    </form>
    </div>
</body>
</html>


这篇关于是否有可能触发“选择文件上传"?对话框,带有单个asp按钮,而不使用JavaScript,Jquery和Ajax控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆