Wednesday, December 17, 2008

Check a value in a string using Javascript

In .net if we want to check a value whether it is existing in given string
we have contains function which return true or false.
But in javascript we dont have function like this.But we can implement this
by using the function indexOf()

All you need to do is check whether the return value is -1 or not. A return value of -1 implies that the specific letter is not present in the given string.

function checkString()
{
if(str.indexOf("http://")==-1)
{
alert("Value Not Found");
}
else
{
alert("Value Found");

}
}

Monday, December 8, 2008

Random results

This is related to sqlserver.
Our team recently completed a project for a Real estate company, for which we received thank-you letters and e-mails from very happy customers.we have stored this in a table.
we want to show this on page. We chose to display 10 notes, but we didn't want a fixed display because it would be boring and require maintenance. So, we opted to display 10 notes selected at random.

To do this just we have used a simple query which displays
different result at diffent times.

select top 3* from table name order by newid()

Friday, December 5, 2008

Find control in aspx page which has master page

Its easy to find the control in apsx page but we need to write
extra code when we have a master page for the aspx page.

Below is the code which finds control in aspx page which has master page.

Dim content As ContentPlaceHolder
content = Page.Master.FindControl("ContentPlaceHolder1")

Dim labelcontrol As Label
labelcontrol = content.FindControl("LabelId")
labelcontrol .Visible = False


using above code we can find the control.

Thursday, December 4, 2008

Yesterday Date in Sqlserver

Below is the query to get Yesterday date in sqlserver.

Select *
from table
where DATEPART(dd,creationdate) = datepart(dd,dateadd(dd,-1,getdate()))
and datepart(mm,creationdate) = datepart(mm,dateadd(dd,-1,getdate()))
and datepart(yyyy,creationdate) = datepart(yyyy,dateadd(dd,-1,getdate()))