Sunday, October 28, 2012

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.

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>

Friday, August 10, 2012

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




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.
 

Wednesday, August 10, 2011

Failed to generate a user instance of SQL Server

OK.

I know the updates have been real slow... Its more like I am a touch too busy to go on and update the blog. But.... lets pick it up once again and try to revive it...

Here is the one for today !! I was working on a small VS2010 WPF Application when I came across this weird error.

Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.

Searched a bit around the net and found a lot of solutions to it.

The most un-convincing one did the trick.

Goto the below location in WIndows Explorer

C:\Users\\AppData\Local\Microsoft\Microsoft SQL Server Data

Delete the folder SQLExpress.

NJoy !!

Tuesday, October 19, 2010

Unable to cast object of type System.Data.DataRowView to type System.IConvertible

Wow...

Long time.. A lot of distractions. I have been interested in a lot new things. With Windows Phone, Robotics coming into picture, the hobbies and pass-times all changed around.

But to get back on the track.. Here is a very small piece of information that I am sure would help a lot of people.

I encountered the above error while working with a Combobox in a Windows Application.

This would come up every time the form loads and the the SelectedValue of the combobox was selected.

This normally would occur to comboboxes, which are databound.

So here is the problem and the solution.

This is how we usually bind the combobox to data

cboBox.DataSource = data_set.Tables["table_name"].DefaultView;

cboBox.DisplayMember = "field_name";

cboBox.ValueMember = "field_id";


Instead, to resolve this issue all we need to do is first specify the DisplayMember and ValueMember and then Bind.


cboBox.DisplayMember = "field_name";

cboBox.ValueMember = "field_id";

cboBox.DataSource = data_set.Tables["table_name"].DefaultView;


Tuesday, April 6, 2010

App_Offline.htm

Phheeewwwww,

Back after a looong time. Its all been busy so long and was not able to post here something for long.
Now.... I have something to post + I have the time. So here we go....
Learnt a new concept today - App_Offline.htm.

There is a simple way to bring down your ASP.NET 2.0 application. The only thing you have to do is to create simple html file called App_offline.htm and deploy it to your ASP.NET 2.0 web application root directory. The rest is handled by ASP.NET runtime internal routines

This approach is extremely helpful for scenarios where we need to bring down the application instantly for some quick updates or any other purpose.

It stops processing new incomming requests and serves the contents of this App_offline.htm file.

Since the whole application domain is unloaded, all application files and assemblies are unlocked and we can make any necessary changes. When done with the changes, all we need to do is rename or delete App_offline.htm file and the next incoming request will bring the ASP.NET 2.0 web application back online.

There is also one great use of this. In order to unlock any attached Database files. This way, they are released and unlocked to be copied over anywhere.


Hope this helps someone, somehow.

Tuesday, June 30, 2009

NotAvailableException was unhandled

Off late I developed another new aspect of my field and I am now challanging myself now into yet another field of programming..... GAME DEVELOPMENT.

Startd off with a very simple yet very effective tutorial found at
http://blogs.msdn.com/coding4fun/archive/2006/11/03/940223.aspx

The moment I had everything set up nicely for my first DirectX application to run, it failed with a very strange exception
"NotAvailableException"

Well after a decent amount of search... I could finally get the solution.. and was really very embarassed to see that to be a problem..

I was using the Generic Video Card Drivers that were being installed by default by windows and all it needed was to install the latest Video Card Drivers from the vendor's site and VIOLA...
It works..

Learning - Before any Dx programming, make sure you are up to date with the Drivers for all your hardware....

Njoy :)

Thursday, May 28, 2009

The changes you have made require the following tables to be dropped and re-created

This morning working on newly installed SQL 2008, I stumbled across this strange problem.

Now at first go, it did not look too severe a problem and I tried to go through the options under tools menu to find out if there was any such option available.

An here is the answer:-








NJoy :)
Ashutosh

Wednesday, April 29, 2009

Adding multiple XAMLs to a single XAP file

Just recently I started learning Silverlight and its pretty cool. I am loving it and trying to find new things everyday out of it.
Today, while working with the XAMLs and XAPs, I noticed that the Silverlight controls when referred onto an ASPX page, uses the XAP as the source.
Now thats where I had an issue.
I had created quite a few UserControls (XAMLs) on a single XAP and had no clue how to distinguish them on the ASPX page.
Here is the solution to it.

For the purpose of differenciating between the two controls, we use its InitParameters property.



As shown in the image above, I had multiple XAMLs for a single XAP

Now I had two ASCX user controls. One of them needed Page.Xaml and the other needed TeamToolbar.xaml.

So to distinguish between the two, I had the following declarations:

On the Page.Ascx -

<asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/AllCoders.xap" InitParameters="ControlID=Page" Width="100%" Height="100%">

And on the TeamToolbar.ascx -

<asp:Silverlight ID="Xaml2" runat="server" Source="~/ClientBin/AllCoders.xap" InitParameters="ControlID=TeamToolBar" Width="100%" Height="100%">



And on the App.xaml.cs, where its all initialized, we need to check which control is to be loaded.



In the Application_Startup method, this is how we need to check for it.:

Monday, December 22, 2008

Displaying Images from Database into an ASP:IMAGE control

Just recently, while working on a project, I stumbled upon a need to fetch images from the SQL Database and display them in the image control on the page.

I did a bit of research and landed upon a concept of using GENERIC HANDLERS for that purpose.

I found that really useful as compared to any other approach of saving the files to disk and setting the URLs etc.

Here is what can be done:

1. Add a new GENERIC HANDLER (ImageDisplay.ashx) to the project.
2. Set the ImageControl's ImageUrl to this ashx page..
imgDisplay.ImageUrl = "ImageDisplay.ashx?imageId=1";
where imageId is the Database ID of the image that needs to be fetched.
3. Now write code to fetch data from Database for that imageId in the ProcessRequest event of the ashx page.

public void ProcessRequest(HttpContext context)
{
Int32 imageId = Convert.ToInt32(context.Request.QueryString["imageId"]);

// This is the function that returns the Byte Array from the Database
Byte[] pict = GetImageById(imageId);
context.Response.ContentType = "image/bmp";
context.Response.OutputStream.Write(pict, 0, pict.Length);
}

4. The method GetImageById would depend upon the Database and data-type that you have for the column for image. Since I had a MySQL database with BLOB column, which can hold a Byte[], the method was quite simple for me and I just had to pull it out from Database and insert it into a Byte[] object.

-- Ashutosh

Monday, December 8, 2008

TabContainer cannot have children of type.....

Recently, I encountered the problem quite similiar to the one above.....
TabContainer cannot have children of type
'System.Web.UI.WebControls.Repeater'

to be precise...

I googled quite a bit for this error, but could not find much about it.. No wonders.. It was a careless mistake that I had made. Here is the control that caused this issue....

<cc1:tabcontainer id="tabToolbox" runat="server">
<cc1:tabpanel id="pnl" headertext="Most Popular">
<contenttemplate>
<asp:repeater id="rptMostPopular" runat="server">
<itemtemplate>
<asp:linkbutton id="lnkPopular" runat="server" text=""></asp:linkbutton>
</itemtemplate>
</asp:repeater>
</contenttemplate>
</cc1:tabpanel>
<cc1:tabpanel id="pnl2" headertext="Most Viewed">
<contenttemplate>
<asp:repeater id="rptMostViewed" runat="server">
<itemtemplate>
<asp:linkbutton id="lnkPopular" runat="server" text="">&jt;/asp:linkbutton>
</itemtemplate>
</asp:repeater>
</contenttemplate>
</cc1:tabpanel>
<cc1:tabpanel id="pnl3" headertext="Most Emailed">
<contenttemplate>
<asp:repeater id="rptMostEmailed" runat="server">
<itemtemplate>
<asp:linkbutton id="lnkPopular" runat="server" text=""></asp:linkbutton>
</itemtemplate>
</asp:repeater>
</contenttemplate>
</cc1:tabpanel>
</cc1:tabcontainer>

Well...... A very simple reason for getting this error, even on the designer and also at runtime..
I FORGOT THE TAG "RUNAT=SERVER" WHILE DESCRIBING THE TAB PANELS AND therefore could not get the tab-panels to be server side...

This is what raised the issue.

A simple addition of RUNAT=SERVER solves the issue...


Hope this would help someone in need... :)

--Ashutosh