asp:FileUpload控件第一次收到回发 [英] asp:FileUpload control is getting postback on first time
本文介绍了asp:FileUpload控件第一次收到回发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
在我的表单中我使用更新面板更新面板我使用面板。
内部面板im asp :FileUpload控件和一个上传按钮。
当我浏览任何zip文件并第一次点击上传按钮时.hasfile因为文件上传控件的回发而变得虚假。当我第二次上传它变为真实和工作时正确。
请建议我为什么上传控制器首次发布回复...
从下面的评论复制的其他信息
< asp:UpdatePanel ID = UpdatePanel1 runat = 服务器 UpdateMode = 始终 >
< contenttemplate >
< asp:Panel ID = pnlUpload runat = server 字体名称 = Verdana 字体大小 = 11px 样式 = 填充:0px 0px 0px 0px;
border:1px; border-color:#A5C5DE; border-style:solid; 高度 = 120px 宽度 = 100% >
< table < span class =code-attribute> style = width:100%; >
< tr >
< td >
< div id = dvzip runat = server class = 表单 style = background-color:#ffffff!important;
宽度:100%; vertical-align:top >
< fieldset class = curve_qp >
< 图例 class = curve_qp > 导入ZipFile < / legend >
< table id = tblzip runat = 服务器 >
< tr >
< td align = right class = label style = 宽度:25%; >
密码< span class = mandatory_field > * < / span >
< / td >
< td colspan = 2 style = < span class =code-keyword> width:75%; >
< ; asp:TextBox ID = txtSessionPassword TextMode = MultiLine runat = 服务器 < span class =code-attribute> CssClass = formContent
< span class =code-attribute> < span class =code-attribute> 宽度 = 100% 高度 = 50px >
< / td >
< / tr >
< ; tr >
< td class = label 样式 = width:25%; align = 正确 >
选择要上传的文件名< span 类 = mandatory_field > * < / span > ;
< / td >
< td style = width:55 %; >
<% - < asp:FileUpload ID =fileziprunat =serverCssClass =borderWidth =100 %Height =20px
BorderWidth =1pxOnInit =filezip_Init/> - %>
< asp:FileUpload ID = filezip < span class =code-attribute> runat = server CssClass = border 宽度 = 100% 高度 = 20px
< span class =code-attribute> BorderWidth = 1px / >
< / td >
< td style = width:20%; >
< asp:按钮 < span class =code-attribute> ID = btnUpload runat = server 文字 = 上传 的CssClass 跨度> <跨度class =code-keyword> = formbtn curve_qp label
< span class =code-attribute> < span class =code-attribute>宽度 = 108px OnClick = btnUpload_Click / >
< / td >
< / tr >
< / table >
< / fieldset >
< / div >
< / td >
< / tr >
< / table >
< span class =code-keyword>< / contenttemplate >
< 触发器 >
< asp:AsyncPostBackTrigger < span class =code-attribute> ControlID = btnUpload EventName = btnUpload_Click / >
< /触发器 >
解决方案
在更新面板中使用触发器
< 触发器 >
< asp:postbacktrigger controlid = 上传按钮 xmlns:asp = #unknown / >
< / triggers >
为UpdatePanel添加asp:postbacktrigger并提供ControlID。
请参阅下面的代码,它将对您有所帮助。
< asp:UpdatePanel ID < span class =code-keyword> = UpdatePanel1 runat = server UpdateMode = 有条件的 >
< 触发器 >
< asp:PostBackTrigger ControlID = Button1 / >
< / Triggers >
< ContentTemplate >
< asp:Panel runat = server >
< asp:FileUpload ID = FileUpload1 runat = server < span class =code-attribute> / >
< asp:按钮 ID = Button1 runat = server 文字 = 上传 O nClick = Button1_Click / >
< / asp:Panel >
< / ContentTemplate >
< / asp:UpdatePanel >
Hi
In my form im using update panel inside update panel im using panel.
Inside panel im asp:FileUpload control and a upload button.
When i browse any zip file and click upload button first time .hasfile is becoming false becuase of postback of fileupload control.when i upload second time its becoming true and working correctly.
Pls suggest me why the upload conntrol is postbacking for first time...
additional information copied from comment below
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
<contenttemplate>
<asp:Panel ID="pnlUpload" runat="server" Font-Names="Verdana" Font-Size="11px" Style="padding: 0px 0px 0px 0px;
border: 1px; border-color: #A5C5DE; border-style: solid;" Height="120px" Width="100%">
<table style="width: 100%;">
<tr>
<td>
<div id="dvzip" runat="server" class="form" style="background-color: #ffffff !important;
width: 100%; vertical-align: top">
<fieldset class="curve_qp">
<legend class="curve_qp">Import ZipFile</legend>
<table id="tblzip" runat="server">
<tr>
<td align="right" class="label" style="width: 25%;">
Password <span class="mandatory_field">*</span>
</td>
<td colspan="2" style="width: 75%;">
<asp:TextBox ID="txtSessionPassword" TextMode="MultiLine" runat="server" CssClass="formContent"
Width="100%" Height="50px">
</td>
</tr>
<tr>
<td class="label" style="width: 25%;" align="right">
Choose the FileName to Upload <span class="mandatory_field">*</span>
</td>
<td style="width: 55%;">
<%--<asp:FileUpload ID="filezip" runat="server" CssClass="border" Width="100%" Height="20px"
BorderWidth="1px" OnInit="filezip_Init" />--%>
<asp:FileUpload ID="filezip" runat="server" CssClass="border" Width="100%" Height="20px"
BorderWidth="1px" />
</td>
<td style="width: 20%;">
<asp:Button ID="btnUpload" runat="server" Text="Upload" CssClass="formbtn curve_qp label"
Width="108px" OnClick="btnUpload_Click" />
</td>
</tr>
</table>
</fieldset>
</div>
</td>
</tr>
</table>
</contenttemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnUpload" EventName="btnUpload_Click"/>
</Triggers>
解决方案
In update panel use triggers
<triggers> <asp:postbacktrigger controlid="Uploadbutton" xmlns:asp="#unknown" /> </triggers>
Add the asp:postbacktrigger for the UpdatePanel and give the ControlID.
See the code below which will help you.
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="conditional"> <Triggers> <asp:PostBackTrigger ControlID="Button1" /> </Triggers> <ContentTemplate> <asp:Panel runat="server"> <asp:FileUpload ID="FileUpload1" runat="server" /> <asp:Button ID="Button1" runat="server" Text="Upload" OnClick="Button1_Click" /> </asp:Panel> </ContentTemplate> </asp:UpdatePanel>
这篇关于asp:FileUpload控件第一次收到回发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文