Dot Net Learning Zone Blog

A blog about to learn Dot Net

Regular Expression for Alphanumeric, float and Max Length in Multi Line

Posted by Rajesh on March 10, 2009

Alphanumeric with White space                                                  :- ^[a-zA-Z0-9 ]+$
For Float  length of integer part 9 and fraction part 4        :-  ([0-9]{1,8}(\.[0-9]{0,4})?|\.[0-9]{1,4})
Max Lenght  in MultiLine TExt BOX                                            :-  “^.{0,255}$”

Posted in Regular Expression | Leave a Comment »

How to get value using SP_EXECUTESQL

Posted by Rajesh on March 10, 2009

DECLARE @Name varchar(50)
DECLARE @Query nvarchar(200)
DECLARE @ParmDefinition NVARCHAR(500)
SET @Query =’Select  @Name=CompanyName  from CompanyDetail’
SET @ParmDefinition = N’@Name varchar(50) OUTPUT’
EXEC SP_EXECUTESQL @Query,@ParmDefinition,@Name=@Name OUTPUT
SELECT @Name

Posted in SQL, SQL Question | Leave a Comment »

How to Pass Value from Parent to Child popup and Child popup to Parent in ASP.net

Posted by Rajesh on March 10, 2009

I have created two pages – Parent.aspx and Child.aspx

Parent.aspx:-

<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Parent.aspx.cs” Inherits=”_Default” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head runat=”server”>
<title>Untitled Page</title>

<script language=”javascript” type=”text/javascript”>
function OpenPopUP()
{
window.open (‘Child.aspx’,'Child’,'toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=320x,height=350px,top=200px,left=100px’);
return false;
}

</script>
</head>
<body>
<form id=”form1″ runat=”server”>
<div>
<table>
<tr>
<td>
Name
</td>
<td>
<asp:TextBox ID=”txtName” runat=”server” Text=”"></asp:TextBox>
</td>
<td>
<asp:Button ID=”btnSearch” runat=”server” Text=”Search” OnClientClick=”OpenPopUP();” />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>

Child.aspx :-

<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Child.aspx.cs” Inherits=”Child” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head runat=”server”>
<title>Untitled Page</title>

<script language=”javascript” type=”text/javascript”>
function ValuePatentToChild()
{
var Name =  window.opener.document.forms[0].txtName.value;
var setName =  document.getElementById (‘txtChild’);
setName.value =  Name;

}

function ValueChildToParent()
{
var Name =  document.getElementById (‘txtChild’).value;
window.opener.document.forms[0].txtName.value =  Name;
self.close();
}

</script>

</head>
<body onload=”ValuePatentToChild();”>
<form id=”form1″ runat=”server”>
<div>
<table>
<tr>
<td>
<asp:TextBox ID=”txtChild” runat=”server” Text=”"></asp:TextBox>
</td>
<td>
<asp:Button ID=”btnClose” runat=”server” Text=”Close” OnClientClick=”ValueChildToParent();” />
</td>
<td>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>

Posted in ASP.net2.0, Ajax, Java Script | Leave a Comment »

How to count week in month

Posted by Rajesh on February 5, 2009

  public int GetWeekInMonth(int year, int month)

        {

            CultureInfo cinfo = CultureInfo.CurrentCulture;

            Calendar MyCal = CultureInfo.InvariantCulture.Calendar;

            int CountWeek = 0;

            for (int icount = 1; icount < cinfo.Calendar.GetDaysInMonth(year, month); icount++)

            {

                string str = Convert.ToString(MyCal.GetDayOfWeek(new DateTime(year, month, icount)));

                if (str.Equals(“Monday”, StringComparison.OrdinalIgnoreCase))

                {

                    CountWeek = CountWeek + 1;

                }

 

            }

            return CountWeek;

        }

 

 

Posted in Uncategorized | Leave a Comment »

How to create Web Setup Project in Visual studio 2005/2008

Posted by Rajesh on February 5, 2009

Steps:

1.      Create new ASP.NET Web Site

a.      File->Add New Web Site->, Select ASP.net Web Site from template  and choose location file type or http

2.      Right click on website and then add Web Deployment project (WebSite1_deploy”)

If Web Deployment project is not display in IDE then download from http://msdn.microsoft.com/en-us/asp.net/aa336619.aspx  for visual studio 2005 and  http://www.microsoft.com/DOWNLOADS/details.aspx?FamilyID=0aa30ae8-c73b-4bdd-bb1b-fe697256c459&displaylang=en for visual studio 2008 .Install Web Deployment project and then restart your visual studio IDE. Then you can see Web Deployment project  in Build menu “Add Web Deployment Project”.

3.      Right click on WebSite1_deploy then click on Build

After successful build

4.      Add new web setup project in solution, assume project name is “WebSetup1”.Then right click on WebSetup1 and click on Add and select project output. In Project, select website1_deploy and then click on OK ..Now the final step is to build WebSetup1 .After successful build .msi file is created. Now you can install .msi file.

Posted in ASP.net2.0 | Leave a Comment »

Download MCTS Framwork2.0 books

Posted by Rajesh on August 14, 2008

Posted in Download | Tagged: , | 3 Comments »

Project Configuration in Microsoft Visual Source Safe (VSS)

Posted by Rajesh on August 14, 2008

Please follow these steps:

Configuration of VSS
It sounds like you are working with source safe through your development tool. Try the following:
Step 1: Created a blank solution called DotNetNuke.Sln and save it to a directory.
Step 2: Close your development tool.
Step 3: Open “Microsoft Visual SourceSafe 6.0″
Step 4: File -> Create Project …
Step 5: Fill in the Project name and comment
Step 6: Move the blue highlight to the new project
Step 7: File -> Add Files …
Step 8: Browse to the files you want to add, select them and click add.
Step 9: Check the files out to yourself
Step 10: Close source safe
Step 11: Open your development tool and add the code you want to add.
—- When done —
Step 12: Save your work
Step 13: Open “Microsoft Visual SourceSafe 6.0″
Step 14: Move the blue highlight to your project
Step 15: Select the file(s) in the right pane
Step 16: SourceSafe -> Check In …
I think you may find this useful
http://oldlook.experts-exchange.com:8080/Programming/Q_20867690.html
http://www.experts-exchange.com/Programming/Processor_Platforms/Q_21314581.html

Posted in VSS | Tagged: , | 1 Comment »

access the data of Gridview in Rowcommand

Posted by Rajesh on August 11, 2008

Posted in ASP.net2.0 | Leave a Comment »

Find duplicate row in table in SQL

Posted by Rajesh on May 27, 2008

1. Create Table

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

SET ANSI_PADDING ON

GO

CREATE TABLE [dbo].[tbl_Test](

[Id] [int] NULL,

[Name] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL

) ON [PRIMARY]

GO

SET ANSI_PADDING OFF

2. Insert Record

INSERT INTO [Test].[dbo].[tbl_Test]([Id] ,[Name]) VALUES (1,‘a’)

INSERT INTO [Test].[dbo].[tbl_Test]([Id] ,[Name]) VALUES (2,‘b’)

INSERT INTO [Test].[dbo].[tbl_Test]([Id] ,[Name]) VALUES (3,‘c’)

INSERT INTO [Test].[dbo].[tbl_Test]([Id] ,[Name]) VALUES (1,‘a’)

INSERT INTO [Test].[dbo].[tbl_Test]([Id] ,[Name]) VALUES (3,‘c’)

INSERT INTO [Test].[dbo].[tbl_Test]([Id] ,[Name]) VALUES (4,‘m’)

INSERT INTO [Test].[dbo].[tbl_Test]([Id] ,[Name]) VALUES (5,‘p’)

INSERT INTO [Test].[dbo].[tbl_Test]([Id] ,[Name]) VALUES (4,‘m’)

INSERT INTO [Test].[dbo].[tbl_Test]([Id] ,[Name]) VALUES (6,‘d’)

INSERT INTO [Test].[dbo].[tbl_Test]([Id] ,[Name]) VALUES (7,‘y’)

INSERT INTO [Test].[dbo].[tbl_Test]([Id] ,[Name]) VALUES (8,‘o’)

INSERT INTO [Test].[dbo].[tbl_Test]([Id] ,[Name]) VALUES (9,‘f’)

3. Find the duplicate record on the basis on Name field

1)

SELECT DISTINCT * FROM dbo.tbl_Test A

WHERE 1<(SELECT COUNT(*) FROM tbl_Test B

WHERE A.nAME=B.NAME)ORDER BY A.NAME

2)

SELECT ID, NAME FROM dbo.tbl_Test

GROUP BY NAME,ID

HAVING COUNT(*)>1

Posted in SQL Question | Leave a Comment »

How to find assembly has assigned strong name or not?

Posted by Rajesh on May 10, 2008

The Assembly Name object contains information about an assembly, which you can use to bind to that assembly.

AssemblyName asName = null;

asName = AssemblyName.GetAssemblyName(“Path of Assembly”);

if (asName.GetPublicKey() != null)

{

Console.Write(“Assembly has assigned strong name”);

}

else

{

Console.Write(“Assembly has not assigned strong name”);

}

Posted in c# | Leave a Comment »