0

I have Button with id = btnUploadxml , as shown;

<td>
   <div id="divUpload" runat="server">
      <asp:FileUpload ID="FileUpload1" runat="server" 
           style="font-family: Tahoma, Verdana, Arial, Helvetica, MS Sans Serif;font-size: 9pt; font-weight:bolder;" 
           BackColor="White" ForeColor="Black" Height="50px" 
           CssClass="ceva-form-btn btn-dialog" Width="458px" />              
      <asp:Button  Text="Import File" runat="server" ID="btnUploadxml"   />
      <br />
      <br />
    </div>
</td>

And after clicking on the button, control should go to

 Public Sub btnUploadxml_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUploadxml.Click

    If Not FileUpload1.HasFile Then
        ErImport.Text = "ErImport, File required"
        ErImport.Visible = "True"
        'UIValidator.AddErrorSummary("", "Select file to import", "File required")

on the click control should go to My btnUploadxml_Click sub, but some how its giving me error

"System.InvalidOperationException: Operation is not valid due to the current state of the object.".

Please advice !!

boop_the_snoot
  • 3,209
  • 4
  • 33
  • 44
  • 1
    Do you have a lot of form fields? Maybe you need to [increase the limit](https://stackoverflow.com/questions/8832470/operation-is-not-valid-due-to-the-current-state-of-the-object-error-during-pos). – the_lotus Jul 26 '17 at 15:47
  • you are right, after increase the limit its work fine for me.. Thanks !! – user7776356 Jul 26 '17 at 15:52

1 Answers1

0

try to put inside your web.config file this code:

<appSettings>
<add key="aspnet:MaxHttpCollectionKeys" value="2001" />
</appSettings>

You will override the default value that is 1000. Try 2001 or bigger value. The definition of this value is this:

 aspnet:MaxHttpCollectionKeys

Limits the maximum number of items that can be present in any of the client-   provided dictionaries of the HttpRequest object.
FabioTos
  • 41
  • 5