如何在c#asp.net中将ImageButton用作ImageUpload? [英] How to use ImageButton as a ImageUpload in c# asp.net?
本文介绍了如何在c#asp.net中将ImageButton用作ImageUpload?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
如何在c#asp.net中使用像FileUpload这样的ImageButton控件?
我想在ImageButton中上传图片,在ImageButton上点击事件,我想在ImageButton Control中使用FileUpload控件。
请帮帮我。
先谢谢。
Ankit Agarwal
网站开发者
解决方案
< head runat = 服务器 >
< title > < / title >
< script 类型 = text / javascript >
函数chooseFile(){
document.getElementById(FileUpload1)。click();
}
< / script >
< / head >
< body >
< 表格 id = form1 runat = server >
< div >
< 跨度> < span class =code-leadattribute> div style = height:0px;溢出:隐藏 >
< asp:FileUpload ID = FileUpload1 runat = server / >
< / div >
< asp:ImageButton ID = ImageButton1 runat = server OnClientClick = chooseFile(); ImageUrl = btnlogin.png / >
< / div >
< / form >
< / body >
< < span class =code-leadattribute> / html >
试试这样。可以帮忙。
有图像和文件上传控件,隐藏文件上传控件。
使用javascript写一个单击图像时将单击文件上载控件的事件。
< img src = 您的源 önClick = OpenFiledialog / >
< asp:FileUpload ID = upldFile runat = 服务器 style = display:none; / >
< script type = text / javascript >
函数OpenFiledialog(){
document.getElementById('upldFile')。 focus()/ click();
}
< / script > 跨度>
Hello,
How to use ImageButton control like FileUpload in c# asp.net?
I want to image upload in ImageButton, on ImageButton click event, I want to use FileUpload control in ImageButton Control.
Please help me.
Thanks in Advance.
Ankit Agarwal
Website Developer
解决方案
<head runat="server"> <title></title> <script type="text/javascript"> function chooseFile() { document.getElementById("FileUpload1").click(); } </script> </head> <body> <form id="form1" runat="server"> <div> <div style="height: 0px; overflow: hidden"> <asp:FileUpload ID="FileUpload1" runat="server" /> </div> <asp:ImageButton ID="ImageButton1" runat="server" OnClientClick="chooseFile();" ImageUrl="btnlogin.png" /> </div> </form> </body> </html>
Try like this.May help.
Have an image and a file upload control, make the file upload control hidden.
Using javascript write an event which will click the file upload control whenever image is clicked.
<img src="your souce" önClick="OpenFiledialog" /> <asp:FileUpload ID="upldFile" runat="Server" style="display: none;" /> <script type="text/javascript"> function OpenFiledialog() { document.getElementById('upldFile').focus() / click(); } </script>
这篇关于如何在c#asp.net中将ImageButton用作ImageUpload?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文