Tuesday, November 30, 2021

Response.redirect like in javascript insimple html

 // Simulate a mouse click:

window.location.href = "http://www.w3schools.com";

// Simulate an HTTP redirect:
window.location.replace("http://www.w3schools.com");


Jquery bootstrap collapse toggle

 https://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_ref_js_collapse&stacked=h

difference between Varchar and nvarchar and char

 Varchar:-

  1. It is a variable that has a length data type.
  2. It is use to store non-Unicode characters.
  3. It Occupy 1 byte of space for each character.

Nvarchar:- 
  1. It is a variable that has length data type.
  2. It is use to store Unicode characters.
  3. It Occupy 2 bytes of space for each character.

Char:-
  • It is a fixed length data type
  • Used to store non-Unicode characters
  • Occupiers 1 byte of space for each character

Drop down list asp.net C# from database

ddlPositions.SelectedValue = dt.Rows[0]["PostHeld"].ToString();



ddlTypeOfCourt.SelectedValue= courtApplicationDatesDTO.CourtTypeId.ToString();



selectedvalue will work


selecteditem.value will not work on above


but when we set the value to object from drop down selecteditem.value will work as below


courtApplicationDatesDTO.CourtTypeId =  Convert.ToInt32(ddlTypeOfCourt.SelectedItem.Value);

 https://www.c-sharpcorner.com/UploadFile/0c1bb2/fill-Asp-Net-dropdown-list-from-database-table-using-Asp-Net/


https://www.aspsnippets.com/Articles/Bind-Populate-ASPNet-DropDownList-using-DataTable-DataSet-in-C-and-VBNet.aspx

Grid edit and update facility in asp.net C#

 https://www.c-sharpcorner.com/UploadFile/1e050f/edit-and-update-record-in-gridview-in-Asp-Net/


or


<asp:GridView ID="grd_Batch" AutoGenerateColumns="false" runat="server" DataKeyNames="Batch_id"

            AllowPaging="true" PageSize="20" PagerSettings-Position="Bottom" PagerSettings-PageButtonCount="10"

            Width="100%" CssClass="table table-bordered table-hover table-stripped table-condensed table-responsive"

            OnRowEditing="grd_Batch_RowEditing" OnRowCancelingEdit="grd_Batch_RowCancelingEdit" OnRowDataBound="grd_Batch_RowDataBound"

            OnRowUpdating="grd_Batch_RowUpdating" OnRowDeleting="grd_Batch_RowDeleting" OnRowCommand="grd_Batch_RowCommand">

<Columns>

<asp:TemplateField HeaderText="EDIT">

                    <ItemTemplate>

Monday, November 29, 2021

wati.io chatbot for whatsapp documentation

 https://docs.wati.io/reference/post_-serverurl-api-v1-updatecontactattributes-whatsappnumber

Saturday, November 27, 2021

An introduction to Jquery.

 Jquery is a javascript library. Simple syntax of Jquery.


----------------------------**************----------------------------

<!DOCTYPE html>

<html>

<head>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

<script>

$(document).ready(function(){

  $("p").click(function(){

    $(this).hide();

  });

});

</script>

</head>

<body>


<p>If you click on me, I will disappear.</p>

<p>Click me away!</p>

<p>Click me too!</p>


</body>

</html>


An introduction to node.js.

 

  • Node.js is an open source server environment
  • Node.js is free
  • Node.js runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
  • Node.js uses JavaScript on the server
Node.js uses asynchronous programming!

And download node.js from https://nodejs.org/en/

How to download mongodb database. An intro to mongodb database

MongoDB is not a SQL database, it is a document database.


Download  Mongodb compass (The GUI for MongoDB)

https://www.mongodb.com/try/download/compass

Also you have to download mongodb community.

https://www.mongodb.com/try/download/community


-------------------****************---------------------

Also you can use MongoDB Atlas for cloud database.


---------------------***************-----------------------

In mangodb, you can say, collections are your tables.

And documents are your data(records)

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

To find the data in filter(in mongodb compass), enter below code

{ Country: "Brazil" }
and click on find.

------------------------------***********************---------------------------

Creating Login logic for asp.net C# and Stored procedure for finding Login and password

 

  1. Create procedure [dbo].[spLogin]  
  2. (  
  3. @Email nvarchar(50),  
  4. @Password nvarchar(50)  
  5. )  
  6. as  
  7. begin  
  8. Select COUNT(*) from UserRegistration where Email=@Email and Password=@Password   
  9. end  
  10. ---------------------------------
  11. Clicking on Login button

  12. protected void btnLogin_Click(object sender, EventArgs e)  
  13.         {  
  14.               
  15.             string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;  
  16.             using (SqlConnection con=new SqlConnection(CS))  
  17.             {  
  18.                 SqlCommand cmd = new SqlCommand("spLogin", con);  
  19.                 cmd.CommandType = CommandType.StoredProcedure;  
  20.                 con.Open();  
  21.                 cmd.Parameters.AddWithValue("@Email",txtEmail.Text.Trim());  
  22.                 cmd.Parameters.AddWithValue("@Password", Decrypt(txtPassword.Text.Trim()));  
  23.                 int Username = (Int32)cmd.ExecuteScalar();  
  24.                 if (Username == 1)  
  25.                 {  
  26.                     Session["Username"] = txtEmail.Text;  
  27.                     Response.Redirect("Welcome.aspx");  
  28.                     Session.RemoveAll();  
  29.                       
  30.                 }  
  31.                 else  
  32.                 {  
  33.                     lblMessage.ForeColor = System.Drawing.Color.Red;  
  34.                     lblMessage.Text = "Invalid username and password";  
  35.                 }  
  36.             }  
  37.         } 
  38. reference:- https://www.c-sharpcorner.com/blogs/how-to-login-with-encrypted-password-in-asp-net
  39. https://www.c-sharpcorner.com/blogs/how-to-create-user-registration-form-with-encrypted-password-using-asp-net#ReadAndPostComment

Session time in asp.net

 If you want to set the timeout to 20 minutes, use something like this:

    <configuration>
      <system.web>
         <sessionState timeout="20"></sessionState>
      </system.web>
    </configuration>

reference:-  https://stackoverflow.com/questions/1205828/how-to-set-session-timeout-in-web-config
https://www.c-sharpcorner.com/blogs/how-to-set-session-timeout-in-asp-net1

Change the website white background to black in google chrome dark mode - Chrome black extension

 There are two options:-

1)You can change by using

chrome://flags/#enable-force-dark 

>Click on enable(select "enabled with simple cielab based inversion") or (select "enable with selective inversion of everything") and than click on Relaunch.(Screenshot below)

or the best option you can select that I have tested (enabled the selective inversion of non-image elements)


----------------------------------*********************-----------------------------------
2) You can click on Customize Chrome (screenshot below)

>Than click on Colors and themes.(screenshot below)

Friday, November 26, 2021

server.mappath in asp.net

 

  • Server.MapPath(".")1 returns the current physical directory of the file (e.g. aspx) being executed
  • Server.MapPath("..") returns the parent directory
  • Server.MapPath("~") returns the physical path to the root of the application
  • Server.MapPath("/") returns the physical path to the root of the domain name (is not necessarily the same as the root of the application)

Encryption and decryption of password in asp.net

 //For decryption of password

-----------------------------***************************------------------------------

  1. private string Decrypt(string clearText)  
  2.         {  
  3.             string EncryptionKey = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789";  
  4.             byte[] clearBytes = Encoding.Unicode.GetBytes(clearText);  
  5.             using (Aes encryptor = Aes.Create())  
  6.             {  
  7.                 Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 });  
  8.                 encryptor.Key = pdb.GetBytes(32);  
  9.                 encryptor.IV = pdb.GetBytes(16);  
  10.                 using (MemoryStream ms = new MemoryStream())  
  11.                 {  
  12.                     using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write))  
  13.                     {  
  14.                         cs.Write(clearBytes, 0, clearBytes.Length);  
  15.                         cs.Close();  
  16.                     }  
  17.                     clearText = Convert.ToBase64String(ms.ToArray());  
  18.                 }  
  19.             }  
  20.             return clearText;  
  21.         }  

------------------------********************--------------------
For encryption of password

  1.  private string Encrypt(string clearText)  
  2.         {  
  3.             string EncryptionKey = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789";  
  4.             byte[] clearBytes = Encoding.Unicode.GetBytes(clearText);  
  5.             using (Aes encryptor = Aes.Create())  
  6.             {  
  7.                 Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 });  
  8.                 encryptor.Key = pdb.GetBytes(32);  
  9.                 encryptor.IV = pdb.GetBytes(16);  
  10.                 using (MemoryStream ms = new MemoryStream())  
  11.                 {  
  12.                     using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write))  
  13.                     {  
  14.                         cs.Write(clearBytes, 0, clearBytes.Length);  
  15.                         cs.Close();  
  16.                     }  
  17.                     clearText = Convert.ToBase64String(ms.ToArray());  
  18.                 }  
  19.             }  
  20.             return clearText;  
  21.         } 

How to create foreign key in SQL server

 >First create two tables Customers and Employee tables

>Customer table with Primary key(ID)(screenshot below)


>Employee table with Foreign key as (customer ID)(Screenshot below)

>Right Click on customer ID(screenshot below)

>Click on Add if key is not added, than click on "Tables and columns specifications){screenshot below}


>Select the primary key table (customer table) and foreign key table (employee table){screenshot below}


reference :- https://www.mssqltips.com/sqlservertip/4790/how-to-create-a-sql-server-foreign-key/