Thursday, April 15, 2010

DateFormatString in Asp.net

Even if you change the dateformatstring to {0:d} or something else, sometimes it won't work exactly we intended. We need the short date but it would appear as long date.
- The workaround could be the following :
-Click on gridview properties( at the top right side)
-Click on "Edit Columns"
-select the date column and click on "convert this field into a template field".
It will send the code to aspx source code.
- Then the date will appear as expected.

I guess the dateformat now will be set at the client side.

Wednesday, April 14, 2010

Databse is set to readonly when created a new copy or attached.

-Add the user "Network Service" in the folder where the mdf and ldf file is stored.
-Right click on the database name which is read only in sql server.
-Click on properties -> Options.
-Goto "State"
- Set the "Database Readonly" to false.
-Click on OK

Tuesday, March 17, 2009

Displaying single line validation summary for multiple controls.

protected void Page_Load(object sender, EventArgs e)
{
Page.ClientScript.RegisterOnSubmitStatement(this.GetType(), "mykey", "if (typeof(ValidatorOnSubmit) == \"function\" && ValidatorOnSubmit() == false) alert('Information marked with * must be filled properly.');return false;");
}

Thursday, March 5, 2009

Failed to access IIS metabase problem

Possible Cause:-

         When you install IIS AFTER .NET 2.0 framework, the rights of the ASPNET user had not been set correctly.

Resolution
         Repair (Uninstall if repair does not work for you)  .NET Framework 2.0

Simply run the following from command line to reset the IIS registry settings for aspnet user. Usually framework directory for .Net Framework 2.0 resides under C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>aspnet_regiis -i


References:-

Wednesday, February 25, 2009

Using merge statement in SQL Server 2008

Using MERGE to perform INSERT and UPDATE operations on a table in a single statement.

A common scenario is updating one or more columns in a table if a matching row exists, or inserting the data as a new row if a matching row does not exist. This is usually done by passing parameters to a stored procedure that contains the appropriate UPDATE and INSERT statements. 

With the MERGE statement, you can perform both tasks in a single statement. The following example shows a stored procedure that contains both an INSERT statement and an UPDATE statement. The procedure is then modified to perform the equivalent operations by using a single MERGE statement.


CREATE PROCEDURE dbo.InsertUnitMeasure @UnitMeasureCode nchar(3), @Name nvarchar(25) AS 
BEGIN SET NOCOUNT ON; 
-- Update the row if it exists. 
UPDATE Production.UnitMeasure 
SET Name = @Name WHERE UnitMeasureCode = @UnitMeasureCode 
-- Insert the row if the UPDATE statement failed. 
IF (@@ROWCOUNT = 0 ) 
BEGIN 
INSERT INTO Production.UnitMeasure (UnitMeasureCode, Name) VALUES (@UnitMeasureCode, @Name) END END; GO 
-- Test the procedure and return the results. EXEC InsertUnitMeasure @UnitMeasureCode = 'ABC', @Name = 'Test Value'; 
SELECT UnitMeasureCode, Name FROM Production.UnitMeasure WHERE UnitMeasureCode = 'ABC'; GO 
-- Rewrite the procedure to perform the same operations using the MERGE statement. 

ALTER PROCEDURE dbo.InsertUnitMeasure @UnitMeasureCode nchar(3), @Name nvarchar(25) 
AS 
BEGIN SET NOCOUNT ON;
MERGE Production.UnitMeasure AS target USING (SELECT @UnitMeasureCode, @Name) AS source (UnitMeasureCode, Name) ON (target.UnitMeasureCode = source.UnitMeasureCode) 

WHEN MATCHED THEN 
UPDATE SET Name = source.Name 
WHEN NOT MATCHED THEN 
INSERT (UnitMeasureCode, Name) VALUES (source.UnitMeasureCode, source.Name) OUTPUT deleted.*, $action, inserted.*; END; GO

 -- Test the procedure and return the results.
 EXEC InsertUnitMeasure @UnitMeasureCode = 'ABC', @Name = 'New Test Value'; EXEC InsertUnitMeasure @UnitMeasureCode = 'XYZ', @Name = 'Test Value'; -- Cleanup DELETE FROM Production.UnitMeasure WHERE UnitMeasureCode IN ('ABC','XYZ');


Unable to start T-SQL debugging. could not attach to sql server process in sql server 2008

This error occurs when the debugger cannot register the user with SQL Server 2005 for debugging. 

The most likely cause is the lack of necessary permissions on the SQL 2005 instance. Connecting with system administrator to SQL Server is not sufficient; the Windows login of the Visual Studio user must also be a member of the system administrator role in SQL Server.


Tuesday, December 9, 2008

YUI (Yahoo User Interface)

The Yahoo! User Interface Library (YUI)

The YUI Library is a set of utilities and controls, written in JavaScript, for building richly interactive web applications using techniques such as DOM scripting, DHTML and AJAX. YUI is available under a BSD license and is free for all uses.

  1. What is the YUI Library?

    The Yahoo User Interface (YUI) Library is a coherent collection of JavaScript and CSS resources that make it easier to build richly interactive applications in web browsers. Some pieces of YUI, like the Event Utility, operate under the hood and are simply there to make in-browser programming easier. Others, like the Calendar Control, comprise visual widgets that can be placed on your page with a default look-and-feel.

  2. Why would I choose YUI?

    The YUI Library is free, licenced under a liberal BSD license that permits both commercial and non-profit use. YUI is backed by developers at Yahoo!, where YUI code is used and refined on pages viewed billions of times each day. YUI is increasingly comprehensive, well-documented, and supported by a growing community in the YUI forum

    YUI Dependency Configurator:

    Choose the YUI components you want to use on your page; beneath the button toolbars, the text area will update with the sorted dependency list required to power your desired components. By default, we'll use aggregate (rollup) files where possible and serve the files from yui.yahooapis.com. You can allow rollups and/or set your own base URL path if you choose. The Combine All JS Files option, on by default, generates a URL for your JavaScript files that combines them all into a single file, reducing HTTP requests. If you wish to use hosted files, you can choose between Yahoo and Google Content Delivery Networks. Yahoo's network supports combo-handling; Google's supports SSL.

    Getting Started

  1. Check out the examples of YUI in action. We recommend starting with the Event UtilityDom Collection examples; Event and Dom are part of the YUI Core (along with the YAHOO Global Object) and provide an important foundation for JavaScript developers using YUI. Once you've reviewed those foundational pieces, go on to explore utilities like Drag and Drop and Animation or UI controls like Button, Calendar and TabView. If you're interested in YUI's CSS components, read through the examples for Reset, Base, Fonts, and Grids in that order.
  2. Remember that there are full user's guides for each component here on the website. If you have any questions about a component as you play with the examples, check out the component's user's guide (by following any of the links along the left side of the page) or the searchable API documentation.
  3. Articles: You may also want to check out "Writing Your First YUI Application," an article designed to help you get up and running with YUI, and "Loading YUI: Seeds, Core, and Combo-handling," an article that explores the three most common strategies for including YUI on the page.
  4. You have cheat sheets for each component available on landing pages and downloadable as a full set. These documents support the online user's guides by providing concise print documentation for YUI components.
  5. Start building. You can include YUI scripts and CSS from the YUI download (in the download's /build directory) or directly from Yahoo! servers. The YUI Loader Utility is a client-side loading package that can dynamically pull in YUI scripts as needed, whether from your servers or from ours. And the YUI Dependency Configurator is a great way to calculate an optimized list of script/css includes for your particular implementation.
  6. Become a member of the YUI community. YUI developers and implementers share thoughts and solutions and provide a helping hand in our forums. YUI developers also contribute to the YUIBlog, where you'll find in-depth articles, videos and other great content about YUI and the world of frontend engineering.
and