Saturday, 10 November 2012

Set date after adding month



Set date after adding month 

 var firstdate = document.getElementById('<%= txtdoj.ClientID %>').value;
            var period = document.getElementById('<%= txtproperiod.ClientID %>').value;

var set_start = firstdate.split('/');

            var day = set_start[0];
            var month = (set_start[1] - 1);  // January is 0 so August (8th month) is 7
            var year = set_start[2];
            var datetime = new Date(year, month, day);
            var newmonth = (month + parseInt(period));  // Must convert term to integer
            var newdate = datetime.setMonth(newmonth);

            newdate = new Date(newdate);
            //alert(newdate);

            day = newdate.getDate();
            month = newdate.getMonth() + 1;
            year = newdate.getFullYear();

            // This is British date format. See below for US.
            calcval = (((day <= 9) ? "0" + day : day) + "/" + ((month <= 9) ? "0" + month : month) + "/" + year);

            // mm/dd/yyyy
            calcval = (((month <= 9) ? "0" + month : month)+ "/" + ((day <= 9) ? "0" + day : day)  + "/" + year);

Tuesday, 28 August 2012



Convert from System.Drawing.Image to System.Windows.Controls.Image


 private void updatePictureBox(Image pic, System.Drawing.Image value)
        {
            if (pic.Dispatcher.Thread == Thread.CurrentThread)
            {



                System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(value);
                IntPtr hBitmap = bmp.GetHbitmap();
                System.Windows.Media.ImageSource WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                pic.Source = WpfBitmap;
            }
}

Tuesday, 10 July 2012


URL rewrite in asp.net...


Add below code in global.asax....   


 void Application_BeginRequest(object sender, EventArgs e)
    {
        string orignalurl = "";
        string url = Context.Request.Url.AbsolutePath;
        string url1 = Context.Request.Url.ToString();
        string[] spliturl1 = url.Split('.');
        string ext = "";
        if (spliturl1.Length > 1)
        {
            ext = spliturl1[1].ToString();

        }
        if (ext == "aspx" || ext == "")
        {
            if (!url1.Contains("?"))
            {
                orignalurl = url;
                string[] spliturl = url.Split('.');
                if (url.Equals(spliturl[0]))
                    Context.RewritePath(orignalurl + ".aspx", false);
                else if (url.Equals(url))
                    Context.Response.Redirect(spliturl[0]);
            }
        }
    }

 

Tuesday, 8 May 2012


Hide sub menu-item indent image in asp.net menu control


<!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>Menu StaticEnableDefaultPopOutImage Example</title>
</head>
<body>
    <form id="form1" runat="server">

      <h3>Menu StaticEnableDefaultPopOutImage Example</h3>

      <asp:menu id="NavigationMenu"
        staticenabledefaultpopoutimage="false"
        dynamichorizontaloffset="10"
        staticdisplaylevels="1"
        orientation="Vertical"
        runat="server">

        <items>
          <asp:menuitem navigateurl="Home.aspx"
            text="Home"
            tooltip="Home">
            <asp:menuitem navigateurl="Music.aspx"
              text="Music"
              tooltip="Music">
              <asp:menuitem navigateurl="Classical.aspx"
                text="Classical"
                tooltip="Classical"/>
              <asp:menuitem navigateurl="Rock.aspx"
                text="Rock"
                tooltip="Rock"/>
              <asp:menuitem navigateurl="Jazz.aspx"
                text="Jazz"
                tooltip="Jazz"/>
            </asp:menuitem>
            <asp:menuitem navigateurl="Movies.aspx"
              text="Movies"
              tooltip="Movies">
              <asp:menuitem navigateurl="Action.aspx"
                text="Action"
                tooltip="Action"/>
              <asp:menuitem navigateurl="Drama.aspx"
                text="Drama"
                tooltip="Drama"/>
              <asp:menuitem navigateurl="Musical.aspx"
                text="Musical"
                tooltip="Musical"/>
            </asp:menuitem>
          </asp:menuitem>
        </items>

      </asp:menu>

    </form>
  </body>
</html>

Above Bold property is use for Hide sub menuitem indent image.