Thursday, April 26, 2012

Open new page as a popup window in asp.net



<script type="text/javascript" language="javascript">
        function changeScreenSize(w, h) {
            window.resizeTo(w, h)
        }
</script>

call this script at body onload
<body onload="changeScreenSize(500,300)" >

</body>

Tuesday, April 24, 2012

How to check nullify in SQL SERVER

Select * from TblEmp where address IS NULL


Select * from TblEmp where address IS NOT NULL

Update TblEmp set empcode='E021' where address IS NOT NULL 

How To Disabled right click,copy and paste in asp.net

Define in body tag at design side in asp.net

<body oncontextmenu="return false;" onload="start()" onselectstart="return false;" oncopy="return false;" onpaste="return false;">

Sunday, March 11, 2012

How to show message box with update panel in asp.net


 ScriptManager.RegisterStartupScript(TxtMobileNumber,typeof(Page), "Open Window", "alert('Mobile Number Already Exists')", true);

Saturday, March 10, 2012

GET LATEST INDEX OF CHECKBOX LIST


  string lastValue = string.Empty;
    int lastIndex=0;

        foreach (ListItem listitem in chkSec.Items)
        {
            if (listitem.Selected)
            {
                int thisIndex = chkSec.Items.IndexOf(listitem);

                if (lastIndex < thisIndex)
                {
                    lastIndex = thisIndex;
                    lastValue = listitem.Value;
                }
            }
        }

Thursday, June 16, 2011

How to calculate difference between two date in ASP.NET with C#


         TimeSpan tspan;
         DateTime date1 = Convert.ToDateTime(txtDateFrom.Text);
         DateTime date2 = Convert.ToDateTime(txtDateTo.Text);
         if (date1 > date2)
             tspan = date1.Subtract(date2);
         else
             tspan = date2.Subtract(date1);
         int days = Convert.ToInt32(tspan.TotalDays);

How to get first day of month in ASP.NET

DateTime date = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);