asp.net - Fileupload1 ID tag is not recognizable -
i know there lot of solutions in case nothing working. trying fileupload
tag id in asp.net
server caught in error .it works fine in 1 page when move code in page .here comes error "the name fileupload not exists in current context" have placed fileupload in bootstrap modal .
<div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title " style="text-align:center">email customer</h4> </div> <div class="modal-body"> <form id="form1" runat="server"> <div class="controls controls-to"> <label class="control-label">to:</label> <asp:textbox id="textboxemail" class="form-control" runat="server"></asp:textbox> </div> <div class="inbox-form-group"> <label class="control-label">description:</label><br /> <textarea id="textarea1" name="message" rows="12" class="inbox-editor inbox-wysihtml5 form-control" runat="server"></textarea> </div> <br /> <div class="inbox-compose-attachment"> <!-- fileupload-buttonbar contains buttons add/delete files , start/cancel upload --> <span class="btn green btn-outline fileinput-button"> <asp:fileupload id="fileupload" runat="server" /> </span> <br /> <br /> <br /> <asp:button id="button2" onclick="buttonclick" runat="server" text="button" /> <%-- <asp:button id="button1" runat="server" text="send email"onclientclick="sendemail" usesubmitbehavior="false" causesvalidation="false" />--%> </div>
and end code
protected void buttonclick(object sender, eventargs e) { { long id = convert.toint64(page.request.params["id"]); var invoiceheader = dberp.invoiceheaders.where(x => x.idinvoiceheader == id).firstordefault(); if (invoiceheader == null) return; fileupload file = fileupload; //error shows here byte[] filebyte = null; if (file.hasfile && file.postedfile != null) { //to create postedfile httppostedfile file = fileupload.postedfile;// , here //create byte array file len filebyte = new byte[file.contentlength]; //force control load data in array file.inputstream.read(filebyte, 0, file.contentlength); if (invoiceheader.id_common_resource != null) { common_resources oldres = dbcommon.common_resources.where(x => x.idresources == invoiceheader.id_common_resource).firstordefault(); if (oldres != null) oldres.content = filebyte; else { common_resources res = new common_resources(); dbcommon.common_resources.add(res); res.content = filebyte; invoiceheader.id_common_resource = res.idresources; } } else { common_resources res = new common_resources(); dbcommon.common_resources.add(res); res.content = filebyte; invoiceheader.id_common_resource = res.idresources; } dbcommon.savechanges(); }
and designer.cs
namespace webapp.portal { public partial class invoice { /// <summary> /// form1 control. /// </summary> /// <remarks> /// auto-generated field. /// modify move field declaration designer file code-behind file. /// </remarks> protected global::system.web.ui.htmlcontrols.htmlform form1; /// <summary> /// textboxemail control. /// </summary> /// <remarks> /// auto-generated field. /// modify move field declaration designer file code-behind file. /// </remarks> protected global::system.web.ui.webcontrols.textbox textboxemail; /// <summary> /// textarea1 control. /// </summary> /// <remarks> /// auto-generated field. /// modify move field declaration designer file code-behind file. /// </remarks> protected global::system.web.ui.htmlcontrols.htmltextarea textarea1; /// <summary> /// fileupload control. /// </summary> /// <remarks> /// auto-generated field. /// modify move field declaration designer file code-behind file. /// </remarks> protected global::system.web.ui.webcontrols.fileupload fileupload; /// <summary> /// button2 control. /// </summary> /// <remarks> /// auto-generated field. /// modify move field declaration designer file code-behind file. /// </remarks> protected global::system.web.ui.webcontrols.button button2; } }
wiki
Comments
Post a Comment