Sunday, 1 November 2015

check valid date time or not

  public bool IsValidDatetime(string strValue)
        {

            //return Convert.ToDateTime(strValue)
            DateTime fromDateValue;
            string s = "15/07/2012";
            var formats = new[] { "dd/MM/yyyy", "yyyy-MM-dd" };
            if (DateTime.TryParseExact(s, formats, CultureInfo.InvariantCulture, DateTimeStyles.None, out fromDateValue))
            {
                return true;
                // do for valid date
            }
            else
            {
                return false;
                // do for invalid date
            }
        }

Wednesday, 28 October 2015

How to disable back button after login in c#(Web application)

Add it in deafult.aspx page

<script type="text/javascript">
        window.history.forward();
        function noBack() { window.history.forward(); }

    </script>

Tuesday, 22 September 2015

HTTP Error 500.21 - Internal Server Error Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list

HTTP Error 500.21 - Internal Server Error

Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list




First need to installed aspnet_regiis

the aspnet_regiis is in the bellow path 
C:\Windows\Microsoft.NET\Framework\v4.0.30319


Go to command prompt right click on cmd prompt Run as administrator  and go to the path then type aspnet_regiis.exe -i that's it

Thursday, 11 September 2014

Could not load file or assembly 'EntityFramework' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

Could not load file or assembly 'EntityFramework' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))



To solve the above error you have to do the following things:

Solution:
Clear out the temporary framework files for your project in:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\ 


For Windows 7, the path is:
C:\Users\[username]\AppData\Local\Temp\Temporary ASP.NET Files\

For 64 bit systems with 'Framework' in the path the full path is:
C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\



Thursday, 15 May 2014

Windows service through CMD

To create a service with out using visual studio:
 
We need the exe file what we have to create the ser vice
 sc create **Abcd** start= auto binPath= "E:\Projects\Service\bin\Debug\Service.exe"
 
To Delete a windows Service through CMD:
sc delete **Abcd**

How to send a mail using SMTP server in Dotnet

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Net.Security;
using System.Web;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using HELP;
using System.Web.Configuration;


public bool SendingMail(string strBody = "", string strToMail = "", string subject = "Forgot Password Details.")
        {
            try
            {
                System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
                SmtpClient smtp = new SmtpClient();
                smtp.Host = WebConfigurationManager.AppSettings["SMTP_Host"].ToString();
                smtp.EnableSsl = true;
                NetworkCredential NetworkCred = new NetworkCredential();
                NetworkCred.UserName = WebConfigurationManager.AppSettings["SMTP_UserName"].ToString();
                NetworkCred.Password = WebConfigurationManager.AppSettings["SMTP_Password"].ToString();
                smtp.UseDefaultCredentials = true;
                smtp.Credentials = NetworkCred;
                smtp.Port = Convert.ToInt32(WebConfigurationManager.AppSettings["SMTP_Port"].ToString());
                msg.To.Add(strToMail);
                msg.From = new MailAddress(WebConfigurationManager.AppSettings["FromEmail"].ToString());
                msg.Subject = subject;
                ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
                msg.Body = strBody;
                msg.IsBodyHtml = true;
                smtp.Send(msg);

                return true;
            }
            catch (SmtpException ex)
            {
                return false;
            }
        }



Call from Front end this method in button click.

Tuesday, 22 April 2014

Create a Pop Up Using JavaScript and CSS when click event

<div id="toPopup" style="background: none repeat scroll 0 0 #FFFFFF; border: 10px solid #ccc; border-radius: 3px 3px 3px 3px; color: #333333; display: none; font-size: 14px; left: 50%; margin-left: -402px; position: fixed; top: 20%; width: 800px; z-index: 2;">
    <div class="close" style="background: url('../images/close.png'); cursor: pointer; height: 30px; position: absolute; right: -27px; top: -24px; width: 30px;"></div>
    <span class="ecs_tooltip" style="background: none repeat scroll 0 0 #000000; border-radius: 2px 2px 2px 2px; color: #FFFFFF; display: none; font-size: 11px; height: 16px; opacity: 0.7; padding: 4px 3px 2px 5px; position: absolute; right: -62px; text-align: center; top: -51px; width: 93px;">Press Esc to close
        <span class="arrow" style="border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 7px solid #000000; display: block; height: 1px; left: 40px; position: relative; top: 3px; width: 1px;"></span></span>
    <div id="popup_content" style="margin: 4px 7px;">

"Pop up content"
 </div>

</div>
<div class="loader" style="background: url('../images/Spinningloading.gif'); height: 32px; width: 32px; display: none; z-index: 9999; top: 40%; left: 50%; position: absolute; margin-left: -10px;"></div>
<div id="backgroundPopup" style="z-index: 1; position: fixed; display: none; height: 100%; width: 100%; background: #000000; top: 0px; left: 0px;"></div>

<script type="text/javascript">
    $(document).ready(function () {
        function Click() {
            loading(); // loading
            setTimeout(function () { // then show popup, deley in .5 second
                loadPopup(); // function show popup
            }, 500); // .5 second
            return false;

        }
        $("div.close").hover(
              function () {
                  $('span.ecs_tooltip').show();
              },
                            function () {
                                $('span.ecs_tooltip').hide();
                            }
               );

        $("div.close").click(function () {
            disablePopup();  // function close pop up
        });

        $(this).keyup(function (event) {
            if (event.which == 27) { // 27 is 'Ecs' in the keyboard
                disablePopup();  // function close pop up
            }
        });

        $("div#backgroundPopup").click(function () {
            disablePopup();  // function close pop up
        });
       
        function loading() {
            $("div.loader").show();
        }
        function closeloading() {
            $("div.loader").fadeOut('normal');
        }

        var popupStatus = 0;

        function loadPopup() {
            if (popupStatus == 0) { // if value is 0, show popup
                closeloading(); // fadeout loading
                $("#toPopup").fadeIn(0500); // fadein popup div
                $("#backgroundPopup").css("opacity", "0.7"); // css opacity, supports IE7, IE8
                $("#backgroundPopup").fadeIn(0001);
                popupStatus = 1; // and set value to 1
            }
        }

        function disablePopup() {
            if (popupStatus == 1) { // if value is 1, close popup
                $("#toPopup").fadeOut("normal");
                $("#backgroundPopup").fadeOut("normal");
                popupStatus = 0;  // and set value to 0
            }
        }

    
    });
</script>