Wednesday, 2 October 2013

Operation is not valid due to the current state of the object.

I am getting the below error while binding a gridview.

Operation is not valid due to the current state of the object.

[InvalidOperationException: Operation is not valid due to the current state of the object.]
   System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded() +2692482
   System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding) +61
   System.Web.HttpRequest.FillInFormCollection() +148

[HttpException (0x80004005): The URL-encoded form data is not valid.]
   System.Web.HttpRequest.FillInFormCollection() +206
   System.Web.HttpRequest.get_Form() +68
   System.Web.HttpRequest.get_HasForm() +8743911
   System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +97
   System.Web.UI.Page.DeterminePostBackMode() +63
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +133

This error occurs when form fields are very large in numbers.By default, the maximum value of MaxHttpCollection is 1000.

To solve this error, increase MaxHttpCollection value in web.config.Add the following setting in your web.config's <appsettings> block.

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

You can change the value accordingly as per your need.

Tuesday, 10 September 2013

Fixed Header and Footer using CSS

If you want to create a header and footer part which will be fixed in their place then follow the below steps.

Place the below css in the page.
 <style type="text/css">
        #header
        {
            background: #eee;
            border: 1px solid #666;
            height: 60px;
            left: 0;
            position: fixed;
            width: 100%;
            top: 0;
            text-align: center;
        }
        #content
        {
            margin: 0 auto;
            overflow: auto;
            padding: 80px 0;
            width: 940px;
        }
        #footer
        {
            background: #eee;
            border: 1px solid #666;
            bottom: 0;
            height: 60px;
            left: 0;
            position: fixed;
            width: 100%;
            text-align: center;
        }
    </style>

Place the below content in the page.
<div id="header">
            Header Content
</div>
<div id="content">
           Text part will place here.
</div>
<div id="footer">
            Footer Content
</div>

Run the project by using F5 and see the output.

Wednesday, 17 July 2013

Handler "svc-Integrated" has a bad module "ManagedPipelineHandler" in its module list

If you  will get this error while running your wcf application then you didn't install the prerequistes for ASP.NET 4.

To install the prerequistes go to
Start --> All Programs --> Microsoft Visual Studio 2008 --> Visual Studio Tools --> Open Visual Studio Command Prompt.
Run Visual Studio 2008 Command Prompt as “Administrator”.

Type the following:
     aspnet_regiis.exe -i

Run your application.

Saturday, 13 July 2013

Windows could not start the SQL Server (MSSQLSERVER) service on Local Computer.Error 1069: The service did not start due to a logon failure.

I was getting the same error since I had changed the password of my computer. I have changed in the services after that it is working fine.

Go to Run-->services.msc--> SQl Server(MSSQLSERVER) . Right click --> Properties -->  Click on "Log on" tab. I have changes the password and retype the current windows password again. It works.