Sakshi Kaul

Sakshi Kaul

  • NA
  • 72
  • 7.2k

how to encrypt the EMPID

Apr 1 2019 7:58 AM
Hi
 
I want when user opens the registration form automatically he should get some value in EmpId field
 
for eg when he opens the registration form on portal to fill that he should get the following
page
 
http://localhost:50605/empid=1122000
 
I want empid in encrypted form in Url and lso want firstle all the feilds should be disabled once the user click edit button then only the user can enter or add the data
 
What changes should be done to the following code ?
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Web;  
  5. using System.Web.UI;  
  6. using System.Web.UI.WebControls;  
  7. using System.Data.Sql;  
  8. using System.Data.SqlClient;  
  9. using System.Data;  
  10. using System.Configuration;  
  11. public partial class _Default : System.Web.UI.Page  
  12. {  
  13. SqlCommand cmd = new SqlCommand();  
  14. SqlConnection con = new SqlConnection();  
  15. protected void Page_Load(object sender, EventArgs e)  
  16. {  
  17. con.ConnectionString = @"Data Source=SAKSHIKAUL-LT\SQLEXORESS1;Initial Catalog=registrationForm;Integrated Security=True";  
  18. con.Open();  
  19. {  
  20. if (!this.IsPostBack)  
  21. Label1.Text = "";  
  22. }  
  23. }  
  24. protected void Button1_Click(object sender, EventArgs e)  
  25. { SqlCommand cmd = new SqlCommand("insert into RegistrationTable" + "(EmpId,Nationality,Religion,Gender,Address,EmailId,Hobbies,MaritalStatus) values (@EmpId,@Nationality,@Religion,@Gender,@Address,@EmailId,@Hobbies,@MaritalStatus)", con);  
  26. //string insertQuery = "insert into RegistrationTable(EmpId,Nationality,Religion,Gender,Address,EmailId,Hobbies,Maritalstatus)values (@EmpId,@Nationality,@Religion,@Gender,@Address,@EmailId,@MHobbies,@Maritalstatus)";  
  27. cmd.Parameters.AddWithValue("@EmpId", TextBox1.Text);  
  28. cmd.Parameters.AddWithValue("@Nationality", TextBox2.Text);  
  29. cmd.Parameters.AddWithValue("@Religion", TextBox3.Text);  
  30. cmd.Parameters.AddWithValue("@Gender", TextBox4.Text);  
  31. cmd.Parameters.AddWithValue("@Address", TextBox5.Text);  
  32. cmd.Parameters.AddWithValue("@EmailId", TextBox6.Text);  
  33. cmd.Parameters.AddWithValue("@Hobbies", TextBox7.Text);  
  34. cmd.Parameters.AddWithValue("@Maritalstatus", TextBox8.Text);  
  35. cmd.ExecuteNonQuery();  
  36. Label1.Text = "Registered Successfuly";  
  37. }  
  38. protected void Button2_Click(object sender, EventArgs e)  
  39. {  
  40. cmd.CommandText = "update RegistrationTable set Nationality =' " + TextBox2.Text + "' where EmpId='" + TextBox1.Text + "' ";  
  41. cmd.CommandText = "update RegistrationTable set Religion =' " + TextBox3.Text + "' where EmpId='" + TextBox1.Text + "' ";  
  42. cmd.CommandText = "update RegistrationTable set Gender =' " + TextBox4.Text + "' where EmpId='" + TextBox1.Text + "' ";  
  43. cmd.CommandText = "update RegistrationTable set Address =' " + TextBox5.Text + "' where EmpId='" + TextBox1.Text + "' ";  
  44. cmd.CommandText = "update RegistrationTable set EmailId =' " + TextBox6.Text + "' where EmpId='" + TextBox1.Text + "' ";  
  45. cmd.CommandText = "update RegistrationTable set Hobbies =' " + TextBox7.Text + "' where EmpId='" + TextBox1.Text + "' ";  
  46. cmd.CommandText = "update RegistrationTable set MaritalStatus =' " + TextBox8.Text + "' where EmpId='" + TextBox1.Text + "' ";  
  47. cmd.Connection = con;  
  48. cmd.ExecuteNonQuery();  
  49. Label1.Text = "Updated Successfuly";  
  50. }  
  51. protected void Button3_Click(object sender, EventArgs e)  
  52. {  
  53. TextBox1.Text = "";  
  54. TextBox2.Text = ""//set equal to empty string to all fields  
  55. TextBox3.Text = ""//set equal to empty string to all fields  
  56. TextBox4.Text = ""//set equal to empty string to all fields  
  57. TextBox5.Text = ""//set equal to empty string to all fields  
  58. TextBox6.Text = ""//set equal to empty string to all fields  
  59. TextBox7.Text = ""//set equal to empty string to all fields  
  60. TextBox8.Text = ""//set equal to empty string to all fields  
  61. Label1.Text = "Clear All";  
  62. }  
  63. }

Answers (1)