18 Eylül 2012 Salı

possible cause for a common AjaxControlToolkit error

The full error message:

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.

The working environment is the same as in http://hilaltarakci.blogspot.com/2012/09/using-calendarextender.html.
I have a user control using ajax control toolkit components and i am pretty sure this control works properly on its own. However, when i tried to use the control in another control, i got the above error.
In my case, adding the following lines to the caller user control fixed my problem:

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

i got the idea from here: http://www.vijaykodali.com/Blog/post/2011/11/06/Make-sure-AjaxControlToolkitPropertiesResourcesNET4resources-was-correctly-embedded.aspx
it specifies the reason for the error as

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.

using CalendarExtender

here is some useful links to use CalendarExtender

lets summarize the process:

  • install ajax control toolkit  ( http://ajaxcontroltoolkit.codeplex.com/) to your project via Visual Studio package manager console with command Install-Package AjaxControlToolkit. This creates packages folder in your repository and downloads the assemblies in that folder.. 
  • in your Web.config file add these two statements:
    • <add assembly="AjaxControlToolkit"/> This line goes under configuration->system.web->compilation->assemblies tag.
    • < add tagPrefix= " ajaxToolkit "  assembly= " AjaxControlToolkit "  namespace= " AjaxControlToolkit "  / > This line goes under configuration->system.web->pages->controls tag.
  • use the control as follows:
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix= " cc1" %>

<asp:TextBox ID="TextBoxDogumTarihi" runat="server"/>
<asp:Image ID="ImageDogumTarihi" runat="server" ImageUrl="../images/calendar.png" />
<cc1:CalendarExtender ID="CalendarDogumTarihi" TargetControlID="TextBoxDogumTarihi" runat="server"
                                        PopupPosition="Right"   PopupButtonID="ImageDogumTarihi"   />

In the following image, the above is a CalendarExtender whereas the below is a styled asp.net calendar.

 to customize CalendarExtender see http://www.ezineasp.net/post/Customized-AJAX-Calendar-Control-CSS-Example.aspx

10 Eylül 2012 Pazartesi

mssql - how to remove null constraint

i spent almost 5 hours for removing a null constraint this evening !!!
here is how to do so:

to view constraints on a table: (http://bytes.com/topic/sql-server/answers/710346-how-do-i-view-table-information-such-constraints)

EXEC sp_help  ThisIsMyTable

to drop a constraint:

ALTER TABLE [ThisIsMyTable] DROP CONSTRAINT [ConstraintName]

to make a non-nullable field nullable: (http://stackoverflow.com/questions/3370159/how-to-remove-not-null-constraint-in-sql-server-using-query)


code-first wants to recreate the database although the backing model is not changed

When the database is in use in production, you do not have the chance of losing data anymore.. Even though i did not make any changes in the data model, code first wanted to recreate the database by throwing an error message such as

The model backing the 'mycontext' context has changed since the database was created. Consider using Code First Migrations to update the database.

My problem is pretty much the same : http://stackoverflow.com/questions/10254613/mvc3-and-code-first-migrations
" In short, even if Db-s are the same migration table data might not be - and hash comparison may fail."
And luckily, the solution in the link worked for me..
I examined the migration difference by running the following command in package manager:

Update-Database -Script

.. and solved the problem by finding the  INSERT INTO [__MigrationHistory] ...  statement and executing it on ms sql server..

This workaround part of this answer explains the cause of the error: http://stackoverflow.com/questions/9516341/code-first-dbmigrator-causes-error-when-building-from-different-machines/11398366#11398366
According to the answer, the naming of association tables appears to be of an indeterminate order in EF causing the above error.