Thursday, June 18, 2009

Refresh a content page without refreshing master page Vs Avoid flicker when click on the link

The master page class derives from the UserControl class. When the application is executing, the master page just like a child control. So we can say the master page is not a true page. “.And, when the page loads, we can notice the navigationURL of the Browser address bar is the content page's, but not the master page's.Because of that we cannot refresh a content page without refreshing master page .But we can avoid flickering with fallowing code by put one <HEAD> tag in the master page.

<meta http-equiv="Page-Enter" content="blendTrans(Duration=0)"/>

<meta http-equiv="Page-Exit" content="blendTrans(Duration=0)"/>

Friday, June 5, 2009

ASP.NET Master page Set Background Image to Table

Problem :When we set ASP Net - Master Page background image it only visible from pages in root directory
Solution : The images which are used in Masterpage should be set in the code behind file as fallow .
The runat='Server" attribute should be added to the controller which are going to set background image and ID should be set to that controller.
<td runat="server" id="tb1">set back ground image with code</td>

In the code behind page image should be set using ResolveClientUrl() method
protected void Page_Load(object sender, EventArgs e)
{
tb1.Style[HtmlTextWriterStyle.BackgroundImage] = ResolveClientUrl("~/App_Themes/Images/1-sri-lanka.JPG");
}


Tuesday, June 2, 2009

Sql Date Time Formatting

Remove Time Part From DateTime
---------------------------------
SELECT GETDATE() /// 2009-06-25 12:03:56.640
Declare @mydate DATETIME
SET @mydate=GETDATE()

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

1.Get Out put as Type of DateTime with zero time
SELECT DATEADD(day, DATEDIFF(day, '20000101',@mydate), '20000101')
or
SELECT DATEADD(DAY, 0, DATEDIFF(DAY,0,@mydate))
or
SELECT DATEADD(dd, DATEDIFF(dd, 0, @mydate), 0)

out put :2009-06-25 00:00:00.000

2.Get Out put as Type of Varchar without time

SELECT CONVERT(VARCHAR(10),@mydate, 103)
out put :25/06/2009

Or
SELECT CONVERT(VARCHAR(10), @mydate, 120)
out put :2009-06-25