About Me

My photo
a Dynamic and Energetic guy.....

Monday, December 6, 2010

Create a textbox watermark using JQuery


<style
type="text/css">


.watermark

{


color: lightgrey;


font-style: italic;

}


</style>


<!--Add JQuery library reference-->


<script
type="text/javascript"
src="Scripts/jquery-1.4.1.js"></script>





<script
type="text/javascript">



     $(document).ready(function () {

     var val = "User Name";





     //assign some watermark value into variable

     if ($("#HeadLoginView_LoginUser_UserName").val() == "") {

     $("#HeadLoginView_LoginUser_UserName").val(val);

     }

     //Check if user and enter into the textbox and remove the class we have assigned on focus event of the text Box

     $("#HeadLoginView_LoginUser_UserName").focus(function () {

     if (this.value == val) {

     this.value = "";

     $("#HeadLoginView_LoginUser_UserName").removeClass("watermark"); //remove class when user focus on the textbox

     }



     });

     // If user did not enter any value in the text box then assign back the watermark value and assign the class

     $("#HeadLoginView_LoginUser_UserName").blur(function () {



     if (this.value == "") {

     this.value = val;

     $("#HeadLoginView_LoginUser_UserName").addClass("watermark"); // Add class to the textbox

     }

     });

     });


</script>

Saturday, December 4, 2010

Importance of Web.Config file

<?xml
version="1.0"?>



<configuration>

<appSettings>

<!-- Have to give write permissions for this folder-->

<add
key="LogFilePath"
value="c:\logs\vonquest.web.log"/>

</appSettings>



<connectionStrings>

<!--We can give one or more conncetion strings-->

<add
name="ConnectionString"


connectionString="Data Source=88.88.88.888,555;Integrated Security=True;user=abc;password=abc123;Database=MyDatabase; Trusted_Connection=no"


providerName="System.Data.SqlClient" />

</connectionStrings>



<system.web>

<!--When user's browser in different culture it is difficult to set one specific ciltute-->

<!--To get rid from that problem we can set UICulture & Culture-->

<globalization
uiCulture="en"
culture="en-AU"/>



<compilation
debug="true"
targetFramework="4.0" />



<pages
theme="Default"
enableEventValidation="false"/>

<!--Set the Time Out period-->

<sessionState
mode="InProc"
timeout="20" />



<!--For dissabling errors to end user, we can redirect to an eror page-->

<customErrors
mode="RemoteOnly"
defaultRedirect="~/Errors/GeneralError.aspx" ></customErrors>



<!--We can pick authentication mode (1)Annonymouse (2)Windows (3)Forms-->

<authentication
mode="Forms">

<forms
loginUrl="~/Default.aspx"
defaultUrl="~/Default.aspx" />

</authentication>



<!--Setting no permission for unwanted users, user should log in to the system to view pages -->

<authorization>

<deny
users="?"/>

</authorization>

</system.web>



<location
path="App_Themes">

<system.web>

<authorization>

<allow
users="*"/>

</authorization>

</system.web>

</location>



<location
path="Images">

<system.web>

<authorization>

<allow
users="*"/>

</authorization>

</system.web>

</location>



<location
path="Scripts">

<system.web>

<authorization>

<allow
users="*"/>

</authorization>

</system.web>

</location>



<location
path="favicon.ico">

<system.web>

<authorization>

<allow
users="*"/>

</authorization>

</system.web>

</location>



<!--Setting pages to access any user, no need to log in-->

<location
path="Account/Register.aspx">

<system.web>

<authorization>

<allow
users="*"/>

</authorization>

</system.web>

</location>



<location
path="Errors/GeneralError.aspx">

<system.web>

<authorization>

<allow
users="*"/>

</authorization>

</system.web>

</location>



<location
path="ContactUs.aspx">

<system.web>

<authorization>

<allow
users="*"/>

</authorization>

</system.web>

</location>



<location
path="News.aspx">

<system.web>

<authorization>

<allow
users="*"/>

</authorization>

</system.web>

</location>





<!--Setting up properties to commiunicate with WCF services-->

<system.serviceModel>

<bindings>

<netTcpBinding>

<binding
name="vqNetTcpBinding"
transferMode="Buffered"
listenBacklog="500"
maxBufferPoolSize="30000000"
maxBufferSize="30000000"
maxConnections="500"
maxReceivedMessageSize="30000000">

<readerQuotas
maxDepth="32"
maxStringContentLength="30000000"
maxArrayLength="30000000"
maxBytesPerRead="30000000"
maxNameTableCharCount="30000000" />

<reliableSession
inactivityTimeout="00:01:00"
enabled="true" />

<security
mode="None">

<transport
clientCredentialType="None">

</transport>

</security>

</binding>

</netTcpBinding>

</bindings>

<client>

<!--A= Address, B=Binding ,C=Contract-->

<endpoint
name="NetTcpBinding_IUser"
address="net.tcp://localhost:6000/UserSvc"
binding="netTcpBinding"
bindingConfiguration="vqNetTcpBinding"
contract="VonQuest.Interface.IUser" />

<endpoint
name="NetTcpBinding_IGame"
address="net.tcp://localhost:6001/GameSvc"
binding="netTcpBinding"
bindingConfiguration="vqNetTcpBinding"
contract="VonQuest.Interface.IGame" />

<endpoint
name="NetTcpBinding_IUtility"
address="net.tcp://localhost:6002/UtilitySvc"
binding="netTcpBinding"
bindingConfiguration="vqNetTcpBinding"
contract="VonQuest.Interface.IUtility" />

</client>

</system.serviceModel>

<system.webServer>

<modules
runAllManagedModulesForAllRequests="true"/>

</system.webServer>

</configuration>

Thursday, November 11, 2010

Usefull .NET code stuff

Show only the short time in a grid
<%# String.Format("{0:g}", Eval("ShuffleTime")) %>  eg:- 22/11/2010 3:39 PM

There are so many useful formats
<%# String.Format("{0:d}", Eval("ShuffleTime")) %>  eg:- 22/11/2010

<%# String.Format("{0:G}", Eval("ShuffleTime")) %>  eg:- 22/11/2010 3:39:55 PM

<%# String.Format("{0:M}", Eval("ShuffleTime")) %>  eg:- November 22

<%# String.Format("{0:t}", Eval("ShuffleTime")) %>  eg:- 11:05 AM


Bind a DataSet/DataTable directly to a DropDown

            DataSet dsUnitTypes = ((PageBase)(this.Page)).Services.Game.GetCodeValuesForCodeHeaderName("UnitType");
            ddlGameTypes.DataSource = dsUnitTypes.Tables[0];
            ddlGameTypes.DataTextField = "Description";
            ddlGameTypes.DataValueField = "CodeID";
            ddlGameTypes.DataBind();

Wednesday, October 6, 2010

Stored Procedure with two EXEC commands, row filtration & order with dynamic parameter


 


 


 

ALTER
PROCEDURE [dbo].[ip_ListingSearch]

@State varchar(200),            

@SalesRegionID int    ,        

@DistrictID int        ,        

@SuburbID varchar(200),        

                            

@bedrooms varchar(20),        

@bathrooms varchar(20),        

@carspaces varchar(20),        

@EER decimal            ,        

                            

@PropertyType varchar(200)    ,

@DevelopmentName varchar(200),

@LandSize int                ,

@HouseSize int                ,

@ListingCategoryCodeID int    ,

@ListingTypeCodeID int        ,

                            

@MinPrice int                ,

@MaxPrice int                ,

@ListingStartDate datetime    ,

@ListingEndDate datetime    ,

@OrderBy varchar(50)
,

@StartRow int
,

@EndRow int
,

@AdvanceQuery varchar(max)

AS


 

SET
NOCOUNT
ON


 

DECLARE @rowTotal INT


 

--bedrooms

DECLARE @bedroomsSign varchar(1)

DECLARE @bedroomCount int

SET @bedroomsSign =
'='

SET @bedroomCount = 0


 

IF @bedrooms <>
''

BEGIN

    SET @bedroomsSign =
SUBSTRING(@bedrooms,0,2)

    SET @bedroomCount =
CAST(REPLACE(@bedrooms,'+','')
AS
INT)

END


 

--bathrooms

DECLARE @bathroomsSign varchar(1)

DECLARE @bathroomCount int

SET @bathroomsSign =
'='

SET @bathroomCount = 0


 

IF @bathrooms <>
''

BEGIN

    SET @bathroomsSign =
SUBSTRING(@bathrooms,0,2)

    SET @bathroomCount =
CAST(REPLACE(@bathrooms,'+','')
AS
INT)

END


 

--carspaces

DECLARE @carspacesSign varchar(1)

DECLARE @carspaceCount int

SET @carspacesSign =
'='

SET @carspaceCount = 0


 

IF @carspaces <>''

BEGIN

    SET @carspacesSign =
SUBSTRING(@carspaces,0,2)

    SET @carspaceCount =
CAST(REPLACE(@carspaces,'+','')
AS
INT)

END


 

DECLARE @AddressType int

SELECT @AddressType = tblCode.CodeID FROM tblCodeHeader INNER
JOIN

dbo.tblCode ON dbo.tblCode.CodeHeaderID = dbo.tblCodeHeader.CodeHeaderID


WHERE
(dbo.tblCodeHeader.CodeTable =
'AddressTypeProperty')
AND
(dbo.tblCode.CodeValue =
'Location')


 


 

DECLARE @ListingParticipantTyepe int

SELECT @ListingParticipantTyepe = dbo.tblCode.CodeID


FROM dbo.tblCodeHeader INNER
JOIN

dbo.tblCode ON dbo.tblCode.CodeHeaderID = dbo.tblCodeHeader.CodeHeaderID


WHERE
(dbo.tblCodeHeader.CodeTable =
'ListingParticipantType')
AND
(dbo.tblCode.CodeValue =
'LISTAGENT')


 


 

SELECT
DISTINCT

dbo.tblSLListing.ListingID, dbo.tblProperty.PropertyID, dbo.tblProperty.PropertyState, dbo.tblSLDistrict.SalesRegionID, dbo.tblSLDistrict.DistrictID,

dbo.tblSuburb.SuburbID, dbo.tblSuburb.PostCode, dbo.tblSLListing.Price, dbo.tblSLListing.ListingDate, dbo.tblSLListing.roomCount, dbo.tblSLListing.bathRoomCount,

dbo.tblSLListing.carSpaceCount, dbo.tblProperty.PropertyTypeCodeID AS PropertyType, dbo.tblSLListing.ObjectStateID, dbo.tblProperty.BlockNumber,

dbo.tblProperty.SectionNumber, dbo.tblProperty.UnitNumber,
ISNULL(dbo.tblAddress.StreetName,
'Address not found')
AS
Address, dbo.tblAddress.Suburb,

dbo.tblProperty.BlockSize, dbo.tblSLListing.EER, dbo.tblSLListing.Size AS HouseSize, dbo.tblSLListingLegalentity.LegalEntityID AS PrimarySalesPersonLLE,

dbo.tblPerson.PersonID AS PrimarySalesPersonID,
ISNULL(dbo.tblSLListing.EstablishedFlag, 0)
AS EstablishedFlag, tblListingCategory.CodeValue AS listingCategory,

dbo.tblSLListing.ListingCategoryCodeID,
ISNULL(dbo.tblPerson.FirstName,
'')
+
' '
+
ISNULL(dbo.tblPerson.LastName,
'')
AS ListingAgent,


COALESCE
(SettlementState.Description, SaleState.Description, dbo.tblSLObjectState.Description)
AS CurrentState, dbo.tblSLObjectState.Description AS ListingState,

dbo.tblSLObjectState.ObjectStateID AS ListingObjectStateID, SaleState.Description AS SaleState, SaleState.ObjectStateID AS SaleObjectStateID,

SettlementState.Description AS SettlementState, SettlementState.ObjectStateID AS SettlementObjectStateID, dbo.tblProperty.PropertyState AS
State,


ISNULL(dbo.tblBodyCorporate.Name, dbo.tblDevelopment.DevelopmentName)
AS DevelopmentName, dbo.tblSLListing.PriceRangeFrom,

dbo.tblSLListing.PriceRangeTo, dbo.tblSLListing.AuctionLocation, dbo.tblSLListing.AuctionTime, dbo.tblSLListing.TenderClosingDate,

dbo.tblSLListing.TenderDeliveryLocation, dbo.tblSLListing.ListingTypeCodeID, dbo.tblSLSale.SaleID

                     ,tblSLListingAttribute.AttributeID,tblPropertyLegalEntity.LegalEntityID as vendor_LEID

into #tempListing

                    

FROM dbo.tblSLListing INNER
JOIN

dbo.tblProperty ON dbo.tblProperty.PropertyID = dbo.tblSLListing.PropertyID

                     LEFT
OUTER
JOIN tblPropertyLegalEntity ON tblPropertyLegalEntity.PropertyID = tblSLListing.PropertyID


INNER
JOIN dbo.tblSLObjectState ON dbo.tblSLObjectState.ObjectStateID = dbo.tblSLListing.ObjectStateID INNER
JOIN

dbo.tblCode AS tblListingCategory ON tblListingCategory.CodeID = dbo.tblSLListing.ListingCategoryCodeID LEFT
OUTER
JOIN

dbo.tblDevelopment ON dbo.tblProperty.DevelopmentID = dbo.tblDevelopment.DevelopmentID LEFT
OUTER
JOIN

dbo.tblBodyCorporate ON dbo.tblBodyCorporate.BodyCorporateID = dbo.tblProperty.BodyCorporateID LEFT
OUTER
JOIN

dbo.tblAddress ON dbo.tblAddress.RelatedTable =
'tblProperty'
AND dbo.tblAddress.RelatedID = dbo.tblProperty.PropertyID AND

dbo.tblAddress.AddressTypeCodeID = @AddressType LEFT
OUTER
JOIN

dbo.tblSuburb ON dbo.tblSuburb.SuburbID = dbo.tblAddress.SuburbID LEFT
OUTER
JOIN

dbo.tblSLDistrict ON dbo.tblSLDistrict.DistrictID = dbo.tblSuburb.DistrictID LEFT
OUTER
JOIN

dbo.tblSLListingLegalentity ON dbo.tblSLListingLegalentity.ListingID = dbo.tblSLListing.ListingID AND

dbo.tblSLListingLegalentity.ListingParticipantTypeCodeID = @ListingParticipantTyepe


LEFT
OUTER
JOIN

dbo.tblPerson ON dbo.tblPerson.LegalEntityID = dbo.tblSLListingLegalentity.LegalEntityID LEFT
OUTER
JOIN

dbo.tblSLSale ON dbo.tblSLSale.ListingID = dbo.tblSLListing.ListingID LEFT
OUTER
JOIN

dbo.tblSLObjectState AS SaleState ON SaleState.ObjectStateID = dbo.tblSLSale.objectStateID LEFT
OUTER
JOIN

dbo.tblSLSettlement ON dbo.tblSLSettlement.SaleID = dbo.tblSLSale.SaleID LEFT
OUTER
JOIN

dbo.tblSLObjectState AS SettlementState ON SettlementState.ObjectStateID = dbo.tblSLSettlement.objectStateID

                     LEFT
OUTER
JOIN tblSLListingAttribute ON tblSLListingAttribute.RelatedObjectID = tblsllisting.ListingID

                    


 

WHERE

    tblProperty.PropertyState = @State

    AND
(@SalesRegionID = 0 or tblSLDistrict.SalesRegionID = @SalesRegionID)

    AND
(@districtID = 0 or tblSLDistrict.DistrictID = @DistrictID)

    AND
(@SuburbID =
''
or tblSuburb.SuburbID in
(select orderID from splitCommaIDs(@SuburbID)))


 

    AND
( @bedrooms =
''
OR
(@bedroomsSign ='+'
AND tblSLListing.roomCount >= @bedroomCount)
OR
(@bedroomsSign='='
AND tblSLListing.roomCount = @bedroomCount))

    AND
( @bathrooms =
''
OR
(@bathroomsSign ='+'
AND tblSLListing.bathRoomCount >= @bathroomCount)
OR
(@bathroomsSign ='='
AND tblSLListing.bathRoomCount = @bathroomCount)
)

    AND
( @carspaces =
''
OR
(@carspacesSign ='+'
AND tblSLListing.carSpaceCount >= @carspaceCount)
OR
(@carspacesSign ='='
AND tblSLListing.carSpaceCount = @carspaceCount))

    AND
( @EER = 0 or tblSLListing.EER = @EER )

    

    AND
(@PropertyType = 0 or tblProperty.PropertyTypeCodeID in
(select orderID from splitCommaIDs(@PropertyType)))

    

    AND
(@HouseSize = 0 or tblSLListing.Size >= @HouseSize)

    AND
(@LandSize = 0 or tblProperty.BlockSize >= @LandSize)


 

    AND
(@MinPrice = 0 or tblSLListing.Price >
= @MinPrice)

    AND
(@MaxPrice = 0 or tblSLListing.Price <= @MaxPrice)


 

    AND
(@ListingStartDate =
''
or tblSLListing.ListingDate >= @ListingStartDate)

    AND
(@ListingEndDate =
''
or tblSLListing.ListingDate <= @ListingEndDate)

    AND
(@ListingCategoryCodeID = 0 or tblSLListing.ListingCategoryCodeID = @ListingCategoryCodeID )

    


 

DECLARE @RowCount as
int

select @RowCount =
count(ListingID)
from #tempListing


 

DECLARE @sQuery as
varchar(1000)

DECLARE @RowBeforeFilter as
int


 


 

--hack to find the row count------------------------------------

SET @sQuery =
'select listingid from #tempListing '
+ @AdvanceQuery

Create
table #test

(

listingid int

)

insert #test

exec(@sQuery)


 

select @rowTotal=count(*)
from #test

--------------------------------------------------------


 


 

SET @sQuery =
'select *,Row_Number() over (order by '
+@orderby +') as rowNumber from #tempListing '
+ @AdvanceQuery


 

declare @pagingQuery as
varchar(2000);

set @pagingQuery =
'with tblResult as ('
+ @sQuery +
') select tblResult.*, '+
convert(varchar(10),@rowTotal)+' as TotalRows from tblResult where tblResult.rowNumber > '
+
convert(varchar(10), @StartRow)
+
' and tblResult.rowNumber <= '
+
convert(varchar(10), @EndRow)
+
';'

exec(@pagingQuery)


 

drop
table #tempListing

drop
table #test


 

SQL Update query with inner join, Script to add table columns

update tbladdress
set tbladdress.state=p.propertystate
from tbladdress as a
inner join tblproperty as p on a.relatedid=p.propertyid
where (a.state is null or a.state='')
      and a.relatedtable='tblProperty'
      and (p.propertystate is not null and p.propertystate <> '')

================================================================
ALTER TABLE SPORT
ADD CreatedDate     datetime,
CreateBy        int,
ModifiedDate     datetime,
Modifiedby      int 


================================================================

Wednesday, August 18, 2010

Sharepoint 2010 New Features / Enhancements

With Sharepoint 2010 we are getting few new features as well as many enhancements.
(1) Development & deployement enhancements
          Creation of Webparts using VS 2010
          Easy deployment of features
    
(2) Administration interface & user experience
          User friendly Central Admin Interface
          Ajax enabled pages
          Modal Popup & less  postbacks
          Ribbon interface 

(3) Performance management
          More templates
          Easy Search
          Easy SSP (Shared Services Providers)
          Database backup & restore
          Performance analyzing

Also we are getting new features in differen layers

Data Modules                 --  Data fetch from External Lists
Server API's                     --  LING
Connected Client API's   --  REST
Pages & UI              --  Silverlight

Thursday, August 12, 2010

SQL Server Reporting Services Expressions

Table Row Visibility by value
=iif(Fields!PctQuota.Value>.9, False, True)


Field Visibility when data is null

=iif(Fields!vendorSolicitor.Value Is Nothing, True, False)

Set Data Field Values
=iif(Fields!ExchangeDate.Value Is Nothing,"",FormatDateTime(Fields!ExchangeDate.Value ,2))

SWITCH
=Switch
(
    Fields!PropertyCategory.Value="N" and sum(Fields!newHouseCount.Value) > 0, sum(Fields!newHouseCount.Value),
    Fields!PropertyCategory.Value="E" and sum(Fields!estHouseCount.Value) > 0, sum(Fields!estHouseCount.Value)
)

Format date
=iif(Fields!ExchangeDate.Value Is Nothing,"",FormatDateTime(Fields!ExchangeDate.Value ,2))

Format Decimal values(Drop decimal places than rounding)
=FormatCurrency(Floor(Sum(Fields!ExpectedAgencyCommission.Value)),0)

Tuesday, August 3, 2010

Site Navigation using Tree View

Drop Tree View Control Form Navigation Tab


Bind Data Source Type to Tree View (Add "Site Map" source)



Add New Item --> Add "SiteMap" from VS templates (extension will be test.sitemap)


Add pages and title of pages to show on Tree View in "test.sitemap"

My Masters