Friday, April 29, 2022

How to change Background Image in one every minute

 > Click on start button

> Type settings in search box

> Click on Personalization

> Click on Background

> Click on dropdown "Change Picture Every"

> And Select 1 minute or two

How to change the flash of window on sound

 > Click on Start button

> Type settings in search box than click on settings

> Click on "Ease of Access"

> Scroll down to left and Click on "Audio"

> Click on drop down list(Show audio alerts visually) and click Flash the active window.

How to change Font Size of text in Windows

 > Click on Start Button

> Type settings and click on settings

> Click on Ease of Access

> Click on slider to change the font size or Click on 125% or 150% in drop down list.

How to connect RJ45 connector to Port, if laptop does not have RJ45 port

 Use External ethernet adaptor for connecting RJ45 Connector to USB.

ASP.NET C# PrintHelper and RPSaveClass helper classes

Create Folder and save file App_Code/Utility/PrintHelper.cs and

App_Code/Utility/RPSaveClass.cs


 https://drive.google.com/file/d/1cWQUNIdv240LG-KqRmw2VbwKd3ObyFlJ/view?usp=sharing


https://drive.google.com/file/d/1NMm62AeZNqNO0Pk_krMGmZFn14wzMpLx/view?usp=sharing



Thursday, April 28, 2022

C# ASP.NET Convert Datetime to textfield

 string.IsNullOrEmpty(txtDateAction.Text) ? (DateTime?)null : Convert.ToDateTime(txtDateAction.Text),

REFERENCE:- https://stackoverflow.com/questions/22689456/passing-null-value-of-datetime-of-asp-net-control-in-c-sharp

C# A class with List of String Array ASP.NET with list of string compare with textfield

 using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;


/// <summary>

/// Summary description for Batch

/// </summary>

public class Batch

{

    public Batch()

    {

        

IN and DISTINCT Clause in SQL SERVER

 select  * from mst_batch where batch_end_date < '2020-04-21'  and batch_end_date>'2019-01-01'

and ScheduleExamDate is null and RequestStatus  in(2,  0)

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

select distinct requeststatus from mst_batch

Wednesday, April 27, 2022

ASP.NET alert redirecting from one page to another within alert

HTML code

 <asp:HyperLink id="btn_StudentRegister" Text="Register Student" runat="server" CssClass="GridViewButton" NavigateUrl='<%# "./ManageStudent/RegisterStudent.aspx?CA_ID=" + Eval("Agency_id") + "&course_id=" + Eval("course_id") + "&Batch_ID=" + Eval("Batch_id") %>'/>

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

C# code

  if (Batch_End_Date < currentdate)

                    {

                        ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "alert('Batch End Date is over, You are not able to Register Student'); window.location='../WelcomeTP.aspx';", true);

                        return;

                    }

ASP.NET grid view OnPreRender event

 <asp:GridView ID="grdBatchDetails" runat="server"  CssClass="table table-responsive" OnPreRender="grdBatchDetails_OnPreRender"

                    AutoGenerateColumns="False" EmptyDataText="No Records Found!" ShowHeaderWhenEmpty="True" 

                    AllowPaging="True" PagerSettings-PageButtonCount="10" PagerSettings-Mode="Numeric" OnDataBound="grdBatchDetails_DataBound"

                    onpageindexchanging="grdBatchDetails_PageIndexChanging"  PageSize="10" CellPadding="4" OnRowCommand="grdBatchDetails_RowCommand"

                    ForeColor="#333333" GridLines="None" Width="100%">


                <Columns>

Monday, April 25, 2022

SQL Case when with where clause when then condition

 SELECT * FROM VW_MST_BATCH where [RequestStatus]=2 and Batch_Status=1

and Agency_id=1 and State_id=


case

when 0 = 0

then State_id

else 5

end

and Training_Partner_id='ESDM-JK-TP-000045'

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

case

when 0 = 0

then State_id

else ''

end

and Training_Partner_id='ESDM-JK-TP-000045'

Friday, April 22, 2022

Encryption of password with Form Authentication and other techniques

System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("Yash@123", "md5").ToLower()

FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "SHA1");

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

C# code

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;


public partial class DecryptPassword : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

        

    }

Thursday, April 21, 2022

Word wrap in Visual Studio - Change large line of code to multiple line - large line to multiline

 Word wrap means that no use of horizontal scroll

>Click on Edit

> Click on Advance

>Click on Word Wrap to enable or disable it

> Check on 'show visual glyphs for word wrap'

How to add comments button in Visual Studio

 >Click on Tools menu

>Click on Customize

> Check on Text editor

>Comments and uncomments will be appear.


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

or 

>Click on Edit

>Click on Advance

>Click on Comment or uncomment section

ASP.NET bulk copy excel file data to sql database table

Upload the file and create upload button. Below is the functionality of upload button

CS file code(below)

 protected void btn_upload_Click(object sender, EventArgs e)

    {

        if (ViewState["CSRF"] != null && Convert.ToString(ViewState["CSRF"]) == Convert.ToString(Session["randomno"]))

        {

            DataTable dtExcelData = new DataTable();


            if (FileUpload1.HasFile)

            {

                //Upload and save the file

                try

                {

ASP.NET Button "Are you sure" alert or confirmation

 <asp:Button ID="btnRecover" runat="server" Text="Recover" CssClass="btn btn-danger"

                            OnClientClick="return confirm('Are you sure to Recover this Batch ?')" OnClick="btnRecover_Click" />

Wednesday, April 20, 2022

How to create batch file for opening multiple programs in window 10 Chrome powershell power shell


Create (example notepad.bat) file and paste below code(Note :- if spaces in url {example:- program file} than use quotes "program file" else write simple):-



 START C:\Windows\NOTEPAD.EXE




START C:\"Program Files\Microsoft Visual Studio"\2022\Community\Common7\IDE\devenv.exe


start C:\"Program Files (x86)\Microsoft SQL Server Management Studio 18"\Common7\IDE\Ssms.exe


START C:\"Program Files (x86)"\Google\Chrome\Application\chrome.exe "gmail.com" "mail.live.com" "sonipat.gov.in"  "panipat.gov.in" "karnal.gov.in" "https://www.aiims.edu/en/notices/recruitment/aiims-recruitment.html"  http://www.nhmharyana.gov.in/page?id=37" "https://hartronservices.com/advertisement/" "https://iasri.icar.gov.in/employment-notice/" "https://www.becil.com/vacancies" "https://www.iari.res.in/index.php?option=com_content&view=article&id=706&Itemid=471"


start C:\"Program Files\Mozilla Firefox"\firefox.exe "email.gov.in" "localhost" "esdm-skill.deity.gov.in"




How to auto shutdown or auto start a program in windows 10

 https://www.c-sharpcorner.com/article/how-to-schedule-automatic-shut-down-in-windows-10/

Monday, April 18, 2022

Github not able to svn checkout by username and password

>If by username and password, you are not able to svn checkout

>Than use token as password.


  1. In the upper-right corner of any page, click your profile photo, then click Settings.
  2. In the left sidebar, click Developer settings.
  3. In the left sidebar, click Personal access tokens.
  4. Click Generate new token.
  5. Give your token a descriptive name.

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




How to use Cookies in ASP.NET Cookies.cs

 Add Cookies.cs file in App_Code/Utility

https://drive.google.com/file/d/1h4bqFdiA8Hikcj5q7V-Ik9NkVF2at5F5/view?usp=sharing


In this we have also aadhar card verification.

Logout page in ASP.NET Logout.aspx.cs

 using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;


public partial class View_Logout : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

       

    }


    protected void Page_PreInit(object sender, EventArgs e)

    {

        Response.Redirect(Page.ResolveUrl(@"~/Login.aspx"));

    }

}

How to download or export PDF file in ASP.NET grid

 private void ExportGridToPDF(GridView GridView1)

    {


        try

        {

            using (StringWriter sw = new StringWriter())

            {

                using (HtmlTextWriter hw = new HtmlTextWriter(sw))

                {

                    //To Export all pages

                    GridView1.AllowPaging = false;

                    this.BindGrid();

                    GridView1.Columns[19].Visible=false;

                    GridView1.RenderControl(hw);

                    StringReader sr = new StringReader(sw.ToString());

                    Document pdfDoc = new Document(PageSize.A2, 10f, 10f, 10f, 0f);

                    HTMLWorker htmlparser = new HTMLWorker(pdfDoc);

                    PdfWriter.GetInstance(pdfDoc, Response.OutputStream);

                    pdfDoc.Open();

                    htmlparser.Parse(sr);

                    pdfDoc.Close();


                    Response.ContentType = "application/pdf";

                    Response.AddHeader("content-disposition", "attachment;filename=LevelWiseCourseReport+'" + System.DateTime.UtcNow.ToString() + "'.pdf");

                    Response.Cache.SetCacheability(HttpCacheability.NoCache);

How to download or export file to excel in ASP.NET grid

 private void Export2Excel()

    {

        DataTable dt = new DataTable();

        try

        {


            SqlParameter[] para = new SqlParameter[]

           {

               new SqlParameter("@CA_ID",drp_certifying.SelectedIndex>0?Convert.ToString(drp_certifying.SelectedValue):null),

               new SqlParameter("@TP_Id",drp_trainingPartner.SelectedIndex>0?drp_trainingPartner.SelectedItem.Value:null),

               new SqlParameter("@State_Id",drp_State.SelectedIndex>0?drp_State.SelectedItem.Value:null),

               new SqlParameter("@Exam_Result",ddlResult.SelectedIndex>0? ddlResult.SelectedItem.Value:null),

Wednesday, April 13, 2022

Code if you are not login and you login to logged in page, Redirect to Login.aspx

 Code for this is below:-


protected void Page_Init(object sender, EventArgs e)

    {

        Response.Cache.SetCacheability(HttpCacheability.NoCache);

        Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));

        Response.Cache.SetNoStore();


        Browser.ClearBrowserData();

        Page.ViewStateUserKey = Session.SessionID;

        Response.Cache.SetValidUntilExpires(true);

    }


 protected void Page_Load(object sender, EventArgs e)

    {

        if (!Page.IsPostBack)

ASP.NET exception handling ExceptionHandler.cs

 Create App_Code/Utility/ExceptionHandler.cs


using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.IO;

using System.Text;

using System.Globalization;

using System.Data.SqlClient;

using System.Diagnostics;

using System.Reflection;


ASP.NET Encryption Encryption.cs

 Create Folder App_Code/Utility/Encryption.cs


#region XD World Recipe V 3

// FileName: Encryption.cs

// Author: Dexter Zafra

// Date Created: 3/20/2009

// Website: www.ex-designz.net

#endregion

using System;

using System.Collections.Generic;

using System.Text;

using System.Security;

using System.Security.Cryptography;

using System.Web.Services;

using System.IO;

How to disable back button in ASP.NET C#

 public void disablebrowserbackbutton()

    {


        Browser.ClearBrowserData();

    }

How to use captcha in asp.net using handler(also see handler in kapooryash.blogspot.com)

    protected void refreshimgbtn_Click(object sender, ImageClickEventArgs e)

    {

        Page.MaintainScrollPositionOnPostBack = true;

        txt_captch.Text = null;

        captcha.ImageUrl = "~/CaptchaHandler.ashx?r=" + DateTime.Now.Ticks.ToString();

        SetCaptchaText();

        txtuserName.Focus();

    }


private void SetCaptchaText()

    {

        try

        {

How to create captcha Image (asp.net) CaptchaImage.cs

 using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

//using System.Web.UI.aspxlControls;

using System.Drawing;

using System.Drawing.Drawing2D;


public class CatpchaImage

{

    public static string SESSION_CAPTCHA = "CAPTCHA";

    

How to create captcha handler(asp.net) CaptchaHandler.ashx

 <%@ WebHandler Language="C#" Class="CaptchaHandler" %>


using System;

using System.Web;

using System.Drawing;

using System.Drawing.Text;

using System.Drawing.Imaging;

using System.Drawing.Drawing2D;

using System.IO;

using System.Web.SessionState;


//namespace CaptchaControl

//{


    public class CaptchaHandler : IHttpHandler, IReadOnlySessionState

    {

ASP.NET logout signout function logic and page load logout option

Response.Cache.SetCacheability(HttpCacheability.NoCache);

        Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));

        Response.Cache.SetNoStore();


        Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1d);

        Response.Expires = -1500;

        Response.CacheControl = "no-cache";

        Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);


        System.Web.Security.FormsAuthentication.SignOut();

        if (Session["trainingpartnersession"] != null)

        {

            Session.Remove("trainingpartnersession");

        }

ASP.NET clear browser data Browser.cs

 Create App_Code/Utility/Browser.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI.WebControls;


/// <summary>

/// Summary description for Browser

/// </summary>

public class Browser

{

public Browser()

{

//

// TODO: Add constructor logic here

//

}


    public static void ClearBrowserData()

    {

        System.Web.HttpContext.Current.Response.Buffer = true;

        System.Web.HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);

        System.Web.HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);

        System.Web.HttpContext.Current.Response.Expires = -15000;

        System.Web.HttpContext.Current.Response.CacheControl = "no-cache";

        System.Web.HttpContext.Current.Response.Cache.SetNoStore();

        System.Web.HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);

        System.Web.HttpContext.Current.Response.AppendHeader("Cache-Control", "no-store");

        System.Web.HttpContext.Current.Response.AppendHeader("Cache-Control", "Must-revalidate");

        System.Web.HttpContext.Current.Response.AppendHeader("Cache-Control", "Proxy-revalidate");


     }



    public static void CrossSiteRequestForgery(HiddenField hfCSEF)

    {

         

        //Code start for Cross Site Request Forgery

        Random randomobj = new Random();

        HttpContext.Current.Session["randomno"] = randomobj.Next();

        hfCSEF.Value = HttpContext.Current.Session["randomno"].ToString();

        //End Code

        

    }

}

ASP.NET cache enable or disable Cache.cs

 Create App_Code/Utility/Cache.cs

#region XD World Recipe V 3

// FileName: Cache.cs

// Author: Dexter Zafra

// Date Created: 8/26/2008

// Website: www.ex-designz.net

#endregion

using System;

using System.Web;

using System.Collections;

using System.Collections.Generic;

using System.Web.Caching;

ASP.NET Master page hiddensession BaseMasterPage.cs

 Create BaseMasterPage.cs file in App_Code/Common/

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;



public class BaseMasterPage : MasterPage

{

    protected HiddenField hiddenSession;


    public BaseMasterPage()

    {

        //

        // TODO: Add constructor logic here

        //

    }


    public string SessionText

    {

        get

        {

            return hiddenSession.Value;

        }

    }

}


ASP.NET security lib for securing string, drop down and radio box SecurityLib.cs

 Create SecurityLib.cs in App_Code/Common Folder 


using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Web.SessionState;

using DataAccessLayer;


public class UtilityLibrary

{

    


    public UtilityLibrary()

    {

        //

        // TODO: Add constructor logic here

        //

Tuesday, April 12, 2022

Creating tough PDF file in asp.net C#

if(a==0){

                                    Sub_Scheme2.Visible = false;

                                    PMU_Address.Visible = false;


                                    Txt_CF.Visible = true;

                                    Txt_RCCF.Visible = true;

                                    Txt_CFClaimforRC.Visible = true;

                                    Lbl_Show_Calculation_Res_CF.Visible = true;

                                    Txt_RCCFClaimforRC.Visible = true;

                                    Lbl_Show_Calculation_Res_RCCF.Visible = true;

                                    Txt_CFClaimforGC.Visible = true;

                                    Lbl_Show_Calculation_Gen_CF.Visible = true;

                                    Txt_RCCFClaimforGC.Visible = true;

Monday, April 11, 2022

MS SQL Server Database error while restoring of database

 > If you get error of "there is no database backup found", while restoring of database.

> Than delete the database that you have created new (blank)

> Restore the database without new (blank) databse.

HTTP Error 500.19 - Internal Server Error website - 80070021 - Error code

>  If you are getting error(below) in running website


> Install IIS

  • Click "Start button"
  • Open control panel
  • Open Program and features
  • Click on 'Turn on windows features on or off'
  • Click IIS services
  • Click: "World Wide Web Services"
  • Click: "Application Development Features"
  • Check (enable) the features. I checked all without CGI.

or

If the problem not resolved
Goto root folder>right click>Properties>Security Tab>Click on Edit>Add> Type 'IIS_IUSRS' and give all the permissions.> 



Thursday, April 7, 2022

How to change double click sound or windows playback sound in windows 10

 >Open Control Panel

> Click on Sound

>Click on Sounds tab (below screenshot).




or

> Right click on right side speaker button

> Click on open sound settings

>Click on Sound control panel

> Click on Sound tab

> Click on start navigation or navigation bar(screenshot below)




>Select dropdown menu and select the sound
> At last click on apply.


How to find MAC address in windows 10

 > Run cmd(command prompt)

> Enter command ipconfig/all

> You will find physical address example 00:1a:c2:7b:00:47 or 00-1a-c2-7b-00-47

This Physical address is the MAC address.

How to install SQL Server on windows 10

 > First install SQL Server express

> Than install SQL Server Management studio(SSMS)--(Select Express Advance option while installing)


reference:- https://phoenixnap.com/kb/install-sql-express

https://blog.devart.com/sql-server-express-edition.html


Previous versions of SQL


https://docs.microsoft.com/en-us/sql/ssms/release-notes-ssms?view=sql-server-2016#1653

Tuesday, April 5, 2022

TextWriter in ASP.NET for creating txt File

 

  1. using (TextWriter txt= File.CreateText (“myfile.txt”)  
  2. {  
  3.    txt.WriteLine (“Comments Started :”);  

IDisposable interface in ASP.NET

 https://www.c-sharpcorner.com/UploadFile/b08196/idisposable-interface-in-C-Sharp/#:~:text=IDisposable%20is%20an%20interface%20that,database%20connections%20and%20so%20on.

public class StudentRegisterBulkupload : IDisposable

{

 public bool CheckStudentExistStart(string adhar)
{
//function to do here
}

  private bool m_disposed = false;

    protected virtual void Dispose(bool disposing)

    {

        if (m_disposed)

            return;


        if (disposing)

        {


        }


        m_disposed = true;

    }


    public void Dispose()

    {

        Dispose(true);

        GC.SuppressFinalize(this);

    }



    ~StudentRegisterBulkupload()

    {

        Dispose(false);

    }

}

ASP.NET Data access layer used with activity log and Bank makster

 Add these three files to App_Code/DataAccess folder

DBManager.cs

DBManagerFactory.cs

IDBManager.cs

https://drive.google.com/file/d/1Rv-GvIRnzwStFl3TP0gMLHMPiQAMwCPw/view?usp=sharing

https://drive.google.com/file/d/1IPmMrPi6BiT0sCjAlMiQ8ed9GjgEEUmT/view?usp=sharing

https://drive.google.com/file/d/1FE1sEuyyIEiUtNDwgCo9a3u-Eq_n2niq/view?usp=sharing


Monday, April 4, 2022

MVC Razor examples

 https://www.geeksforgeeks.org/different-types-of-html-helpers-in-asp-net-mvc/


https://www.c-sharpcorner.com/article/learn-about-razor-view-engine/


https://www.c-sharpcorner.com/article/how-to-create-a-custom-helper-class-in-Asp-Net-mvc/


https://www.geeksforgeeks.org/different-types-of-html-helpers-in-asp-net-mvc/

ASP.NET activity log for web site with sql Tables and stored procedure ActivityLog.cs

Add ActivityLog.cs in App_Code/Common/ActivityLog.cs

 https://drive.google.com/file/d/1_s-QIAlR8inx-P7iv6YDvOfwtSEZTi4x/view?usp=sharing


Also we have to create TempLoginStatus, Users tables and SP_InsertActivityLog stored procedure.

ASP.NET Aadhar Masking AadhaarMasking.cs

Add file to App_Code/Common/AadhaarMasking.cs


 using System;

using System.Data;

using System.Collections.Generic;

using System.Linq;

using System.Web;


/// <summary>

/// Summary description for AadhaarMasking

/// </summary>

public class AadhaarMasking

{

public AadhaarMasking()

{

//

// TODO: Add constructor logic here

//

}

    public string AadhaarNoMasking(string AadhaarNo)

    {

        string MaskAadhaarNo = "";

        if (AadhaarNo.Length > 4)

        {

            MaskAadhaarNo = AadhaarNo.Substring(AadhaarNo.Length - 4).PadLeft(AadhaarNo.Length, 'X');

        }

        return MaskAadhaarNo;

    }

}


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

aspx page code

<asp:Label ID="lbl_AdhaarMask" runat="server" Text='<%#new AadhaarMasking().AadhaarNoMasking(Eval("Adharcard_No").ToString()) %>'></asp:Label>