<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\07536333526\46blogName\75Ashutosh+Vyas\47s+Blog\46publishMode\75PUBLISH_MODE_BLOGSPOT\46navbarType\75BLUE\46layoutType\75CLASSIC\46searchRoot\75http://vyasashutosh.blogspot.com/search\46blogLocale\75en\46v\0752\46homepageUrl\75http://vyasashutosh.blogspot.com/\46vt\75-2391327475702470475', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>
 Add to Technorati Favorites

Instance Failure

Sunday, November 10, 2013 by Ashu

This rather "Strange and UnCommon" error comes up mostly while connecting do database via your C# application.

Reason: - In your connection string, when there is a escape sequence (\), C# converts it to "\\" so that it could be treated the way it needs to.

Therefore if you provide a connection string as "DataSource=ServerName\SQL", c# automatically converts it to  "DataSource=ServerName\\SQL" and reads it the way it needs to.

However, if we actually provide the string something like  "DataSource=ServerName\\SQL" (With Double Back Slashes), then it raises this error causing "Instance Failure".

Solution: Use a SINGLE ( \ ) instead of Double ( \\ ).

Labels: ,

Get a List of all Countries

Tuesday, July 2, 2013 by Ashu

This is a very common requirement that comes up to me in every alternate application that I make. I know there would be a lot of people like me who have the same issue.

At first I thought of consuming a ready made webservice that would give me the list of all countries.

Then upon further research, I found a very simple yet effective solution to my problem:

Here is a function that returns a List of Country Names.

public static List GetCountryList()
        {
            List _CultureList = new List();
            CultureInfo[] _CultureInfo = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
            foreach (CultureInfo _Culture in _CultureInfo)
            {
                RegionInfo _RegionInfo = new RegionInfo(_Culture.LCID);
                if (!(_CultureList.Contains(_RegionInfo.EnglishName)))
                {
                    _CultureList.Add(_RegionInfo.EnglishName);
                }
            }
            _CultureList.Sort();
            return _CultureList;
        }

Only parameterless constructors and initializers are supported in LINQ to Entities

Tuesday, March 5, 2013 by Ashu

This is the error that usually come up when you try to run a LINQ Query and return an object out of this QUERY.

Something like the below example:
var query = (from c in ctx.Clients
                         where l.UserID == userid
                         select new ClientList(c.ClientFirstName, c.ClientLastName,  c.ClientEmail)
                          ).ToList();
Well the Error is Pretty much self explanatory. No Parameterized constructors are allowed for LINQ to Entities...

Workaround ?
Change your Query to something like this..
var query = (from c in ctx.Clients            
                         where l.UserID == userid
                         select new ClientList{ClientFirstName= c.ClientFirstName, ClientLastName= c.ClientLastName, ClientEmail= c.ClientEmail}
                          ).ToList();



Labels: , ,

JQuery Autocomplete "Internal Server Error"

Thursday, December 20, 2012 by Ashu

Hello,

This is something that is very common for all of us to encounter. I encountered this N no. of times during my work and most of the times for all new reasons then before.

Here are a few things that you could look out for:

This error clearly mentions that it is a "Server Error" which means we could not get a proper response back from the server. So chk for these....

1. Make sure you are calling to the correct WebService and correct Method of the webservice.

2. The make sure you pass the correct name of the parameter as requested by the WebMethod.

3. The method should be marked as WebMethod in the WebService.

4. Debug through your Webmethod to see if it fails somewhere.

5. If you are not at all getting the Webmethod to hit (Which was precisely my case), then look for the
    [System.Web.Script.Services.ScriptService]
tag above your asmx.

To allow this Web Service to be called from script, using ASP.NET AJAX, you need to have the  following line on top of your WebService declaration

    [System.Web.Script.Services.ScriptService] 

Hope this helps... 

Introduction to Creating Windows Store Apps Using JS

Wednesday, November 21, 2012 by Ashu

Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "AjaxControlToolkit.Properties.Resources.NET4.resources" was correctly embedded or linked into assembly "AjaxControlToolkit" at compile time, or that all the satellite assemblies required are loadable and fully signed.

Sunday, October 28, 2012 by Ashu

Thats the Error: 

Reason:  AjaxControlToolkit’s control load reference refers to the base System.Web.UI.Control method which is present as a part of the ASP.NET AJAX Libraries and those libraries are referenced only when the ScriptManager is referenced in the page.


Solution: - Add a ScriptManager control to your page.


<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

Labels: , ,

The Controls collection cannot be modified because the control contains code blocks

Friday, August 10, 2012 by Ashu




The above error is very common when we try to access server side values on client side using Javascript.

The solution to this problem is simple.

1. The Server Tag to get values of any variable or property is as below
var propVal = '<%= ServerSideProperty %>';
This is also particulartly helpful when accessing Web.Config values in Javascript as:
var configVal = '<%= ConfigurationManager.AppSettings["ConfigPropName"] %>';

This would raise the above error. And the solution to it, "Replace the "=" with a "#""
So now your properties would be something like
var propVal = '<%= ServerSideProperty %>';
var configVal = '<%= ConfigurationManager.AppSettings["ConfigPropName"] %>';

Now, if you are accessing any Data bound values, such as in a grid view etc, then this would work good for you but for accessing properties or other variables, here is another small piece of code required.

On Page Load, we need to Bind these together using
Page.Header.DataBind();
Unless you do this, you would not be able to access these values and they would return a BLANK.
 

free hit counter web login
www.hit-counter-download.com

about


Hi, Yes I am Ashutosh. Started off on this as a leisure and slowly started to grow interest and now am using this as a platform to share my work with the world. These are the general tasks that I do and general problems and learnings that I gain from my work. I hope these would be useful to someone else as well.

recent posts

recent comments

archives

links

admin